Gergovia的酒交易(Uva11054,Wine trading in Gergovia)
来源:互联网 发布:软件项目经理jd 编辑:程序博客网 时间:2024/05/17 04:25
题目链接
等价转换就是第一个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;}
0 0
- Gergovia的酒交易(Uva11054,Wine trading in Gergovia)
- UVA11054:Wine trading in Gergovia(Gergovia的酒交易)
- uva11054 - Wine trading in Gergovia
- UVA11054 Wine trading in Gergovia
- uva11054 - Wine trading in Gergovia
- UVa11054 Wine trading in Gergovia
- uva11054 - Wine trading in Gergovia(葡萄酒交易)
- [贪心]UVA11054 Wine trading in Gergovia
- UVa11054 - Wine trading in Gergovia UVA
- [问题分解]UVa11054 - Wine trading in Gergovia
- [等价转换]UVa11054 - Wine trading in Gergovia
- UVa11054--Wine trading in Gergovia(贪心)
- Uva11054——Wine trading in Gergovia
- Cpp环境 【poj 2940 】【Uva11054】【Vijos2909】Wine Trading in Gergovia 格尔高维亚的肮脏红酒交易
- 例题8-5 Gergovia的酒交易(Wine trading in Gergovia, UVa 11054)
- Wine Trading in Gergovia
- Wine trading in Gergovia
- UVa11054 poj2940 sdut2370 Wine trading in Gergovia(贪心)
- 搜索算法(深度优先和广度优先)(待更新....)
- java.lang.UnsupportedOperationException: The user must supply a JDBC connection 报错
- 寒假阳哥DIY题目
- udp打洞附源码
- 入门学习Linux常用必会60个命令实例详解 Linux必学的60个命令
- Gergovia的酒交易(Uva11054,Wine trading in Gergovia)
- java程序 一次改变指定目录下所有文件编码(包括子目录中的文件)
- 使用commos-fileupload实现文件上传与下载
- iOS开发:深入理解GCD 第二篇(dispatch_group、dispatch_barrier、基于线程安全的多读单写)
- Android轶事之View要去大保健?View大小自己决定?
- C语言(scanf函数工作原理)
- bootstrap学习细节笔记
- jQuery.Autocomplete实现自动补全(完成)词组功能(详解)
- iOS开发:深入理解GCD 第一篇