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