题目: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 ",ans); return 0; }