luogu_1969 积木大赛

#include <cstdio>
#include <iostream>
using namespace std;
int n,a[100010],ans;

int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        if(a[i]>a[i-1])ans+=a[i]-a[i-1];
    }
    printf("%d\n",ans);
    return 0;
}

  

posted @ 2017-10-11 18:34  wqtnb_tql_qwq_%%%  阅读(92)  评论(0编辑  收藏  举报