Submission
Status:
[PPPPPPPPPPPPP]
Subtask/Task Score:
{100/100}
Score: 100
User: 555eiei
Problemset: ซื้อขายหุ้นซีเค
Language: cpp
Time: 0.009 second
Submitted On: 2025-11-05 18:23:07
#include <bits/stdc++.h>
using namespace std;
int main(){
cin.tie(nullptr)->sync_with_stdio(0);
int n; cin >> n;
vector<int> a(n);
vector<int> diff(n);
for (auto &x : a) cin >> x;
for (int i=1; i<n; i++) diff[i] = a[i] - a[i-1];
long long ans = 0;
for (auto x : diff) if (x > 0) ans += x;
cout << ans;
return 0;
}