Submission
Status:
[PPPPPPPPPPPPP]
Subtask/Task Score:
{100/100}
Score: 100
User: KantaponZ
Problemset: ซื้อขายหุ้นซีเค
Language: cpp
Time: 0.013 second
Submitted On: 2026-03-10 14:34:12
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int nx = 1e5 + 5;
ll n, p[nx], d[nx];
ll ans = 0;
int main() {
ios_base::sync_with_stdio(0), cin.tie(0);
cin >> n >> p[1];
for (int i = 2; i <= n; i++) {
cin >> p[i];
d[i] = p[i] - p[i - 1];
if (d[i] > 0) {
ans += d[i];
}
}
cout << ans;
}