Submission
Status:
[PPPP-SSSSSSSS]
Subtask/Task Score:
{0/100}
Score: 0
User: Seng
Problemset: ซื้อขายหุ้นซีเค
Language: cpp
Time: 0.007 second
Submitted On: 2026-03-07 10:59:25
#include <bits/stdc++.h>
using namespace std;
int p[100005];
int main(){
ios::sync_with_stdio(0);cin.tie(0);
int n;cin >> n;
int ans = 0;
for(int i = 1; i <= n; i++){
cin >> p[i];
if(i == 1) continue;
if(p[i] > p[i-1]) ans += p[i]-p[i-1];
}
cout << ans;
return 0;
}