0
点赞
收藏
分享

微信扫一扫

noip2013 积木大赛 (贪心)


noip2013 积木大赛 (贪心)_贪心

noip2013 积木大赛 (贪心)_git_02

noip2013 积木大赛 (贪心)_noip2013_03

代码:

#include<cstdio>
#include<cstring>
#include<cctype>
using namespace std;

int getin()
{
int ans=0;char tmp;
while(!isdigit(tmp=getchar()));
do ans=(ans<<3)+(ans<<1)+tmp-'0';
while(isdigit(tmp=getchar()));
return ans;
}

int main()
{
int n=getin(),i,x=0,y,ans=0;
for(i=1;i<=n;x=y,i++)
if((y=getin())>x)ans+=y-x;
printf("%d\n",ans);
return 0;
}



举报

相关推荐

0 条评论