UESTC 1817 Complete Building the Houses 贪心
2013-05-03 00:27
190 查看
同是比赛时候的一道水题,比赛的时候以为满层的就不能继续建了,没想到可以忽视它……
搞清题意后,唯一要注意的一点就是ans是long long的
搞清题意后,唯一要注意的一点就是ans是long long的
/* author:jxy lang:C/C++ university:China,Xidian University **If you need to reprint,please indicate the source** */ #include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <queue> #define INF 1E9 using namespace std; int a[1000001]; long long ans=0; int main() { int now; int T,C=0; int n,m,i,t; scanf("%d",&T); while(T--) { ans=now=0; scanf("%d%d",&n,&m); for(i=0;i<n;i++) { scanf("%d",&t); if(now>=t) a[i]=0; else { a[i]=t-now; ans+=a[i]; now=t; } if(i+1-m>=0)//超过m长度 now-=a[i+1-m]; } printf("Case #%d: %lld\n",++C,ans); } }
相关文章推荐
- UESTC 1817——Complete Building the Houses 贪心
- UESTC - 1817 - Complete Building the Houses
- UESTC 4 Complete Building the Houses 树状数组
- cdoj 04 Complete Building the Houses 暴力
- Complete Building the Houses
- android开发小记2-----the user operation is waiting for building workspace to complete
- eclipse运行程序显示the user operation is waiting for "building workspace" to complete
- The user operation is waiting for "Building workspace" to complete--Android开发经验
- The user operation is waiting for "Building workspace" to complete
- the user operation is waiting for "building workspace to" complete (eclipse)
- eclipse the user operation is waiting for building workspace" to complete
- 解决 the user operation is waiting for building woekspace to complete
- The user operation is waiting for "Building workspace" to complete
- the user operation is waiting for "building workspace " complete
- eclipse运行程序显示the user operation is waiting for "building workspace" to complete
- UESTC--1263--The Desire of Asuna(贪心)
- Maven项目导入到Eclipse时Build出现the user operation is waiting for building workspace to complete的问题解决
- UESTC--1263--The Desire of Asuna(贪心)
- 用Python和OpenCV创建一个图片搜索引擎的完整指南 The complete guide to building an image search engine with Python and
- the user operation is waiting for building workspace to complete解决办法