Gergovia的酒交易(Uva11054,Wine trading in Gergovia)
2016-02-01 13:25
555 查看
题目链接
等价转换就是第一个house中的酒直接与第二个house交易,第二个与第三个,。。。
等价转换就是第一个house中的酒直接与第二个house交易,第二个与第三个,。。。
#define _CRT_SECURE_NO_WARNINGS #include<iostream> #include<algorithm> #include<string> #include<sstream> #include<set> #include<vector> #include<stack> #include<map> #include<queue> #include<cstdlib> #include<cstdio> #include<cstring> #include<cmath> using namespace std; const int maxn=100000+10; int main(){ int h[maxn]; int n; long long cost=0; scanf("%d",&n); while (n){ cost=0; for(int i=1;i<=n;i++){ scanf("%d",&h[i]); } for (int i=1;i<=n-1;i++){ if (h[i]!=0){ h[i+1]+=h[i]; cost+=abs(h[i]); h[i]=0; } } printf ("%lld\n",cost); scanf("%d",&n); } return 0; }
相关文章推荐
- djangocms安装技巧
- <19> go random string
- django_cms安装技巧
- 开始使用Google Analytics 示例
- 有用的 Google Analytics Chrome 插件推荐
- 使用DreamHost当GoDaddy域名的服务器 步骤
- redigo长连接/复用
- Go将统治下一个十年
- paper4—Multi-MPE_Trigger_Algorithm—temp
- AlphaGo:黑色方碑?
- paper4—Multi-MPE_Trigger_Algorithm—testing
- paper3—Algorithm1-Engine-Trigger-on-FCD—temp
- paper3—Algorithm2-Engine-Trigger-on-SMD—temp
- Google Guava 类库简介
- 114DNS Public DNS+ 阿里DNS 百度DNS 360 DNS派 Google DNS
- pymongo简单用法
- Google大中华区总裁石博盟用中文拜年
- ZOJ-2855-Google Map【4th浙江省赛】
- LeetCode Algorithms #169 <Majority Element>
- LeetCode Algorithms #171 <Excel Sheet Column Number>