洛谷 1969 积木大赛——水题
题目:https://www.luogu.org/problemnew/show/P1969
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; int n,a,b,ans; int main() { scanf("%d",&n); for(int i=1;i<=n;i++) { scanf("%d",&a); ans+=max(0,a-b); b=a; } printf("%d\n",ans); return 0; }