1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| #include <bits/stdc++.h> using namespace std;
int num[100005]; int main(){ int n; scanf("%d", &n); int flag = 0,cnt,Mini,Min = 1000000002; int tmp; long long ans = 0; for (int i = 0; i < n; i++){ tmp = cnt; scanf("%d", &cnt); if (i !=0 && tmp > cnt) ans += tmp - cnt; } cout << ans << endl; return 0; }
|