积木大赛

题面

水的惊人.......

#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

int ans;
int now;
int a;
int n;

int main()
{
    scanf("%d",&n);
    scanf("%d",&now);
    ans+=now;
	for(int i=2;i<=n;i++)
	{
	    scanf("%d",&a);
		if(a<now)
		{
			now=a;
		}
		else
		{
			ans+=(a-now);
			now=a;
		}
	}
	printf("%d",ans);
	return 0;
}
		 

  

posted @ 2019-08-14 13:13  [jackeylove]  阅读(133)  评论(0编辑  收藏  举报