思维题
思路
见y总视频: https://www.acwing.com/video/2786/
代码
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int n,a[N];
int main()
{
cin>>n;
int res=0,last;
for(int i=1;i<=n;i++)
{
int x;
cin>>x;
if(i>=2&&x>last)
res+=x-last;
last=x;
}
cout<<res<<endl;
return 0;
}