Submission
Status:
[PPPPPPPPPPPPP]
Subtask/Task Score:
{100/100}
Score: 100
User: Krovmoroz
Problemset: ซื้อขายหุ้นซีเค
Language: cpp
Time: 0.011 second
Submitted On: 2026-01-17 09:28:04
#include <bits/stdc++.h>
using namespace std;
int N,pre,cur;
long long ans = 0;
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
cin >> N;
cin >> pre;
for (int i = 0; i < N-1 ; i++) {
cin >> cur;
if (cur > pre) {
ans += 1LL*(cur-pre);
}
pre = cur;
}
cout << ans;
return 0;
}