提交时间:2024-03-02 09:44:06

运行 ID: 133831

#include<bits/stdc++.h> using namespace std; const int N=1e3+10; int p[N]; int n; int res; int main(){ scanf("%d",&n); for(int i=1;i<=n;i++){ scanf("%d",&p[i]); } for(int i=1;i<n;i++){ if(p[i+1]-p[i]>0){ res+=p[i+1]-p[i]; } } printf("%d\n",res); return 0; }