水的惊人.......
#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; }
原文:https://www.cnblogs.com/ainiyuling/p/11351312.html