noip 2018 day1 T1 铺设道路 贪心

Code:

#include<cstdio>
using namespace std;
int main()
{
	
	int last=0,ans=0;
	int n;scanf("%d",&n);
	for(int i=1;i<=n;++i)
	{
		int t;scanf("%d",&t);
		if(t>last)ans+=t-last;
		last=t;
	}
	printf("%d\n",ans);
}

  

posted @ 2018-11-17 10:52  EM-LGH  阅读(100)  评论(0编辑  收藏  举报