Submission
Status:
[PPPPPPPPPPPPP]
Subtask/Task Score:
{100/100}
Score: 100
User: Neozaawwman1
Problemset: ซื้อขายหุ้นซีเค
Language: cpp
Time: 0.009 second
Submitted On: 2026-03-10 22:54:16
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll ans = 0;
int N;
vector<ll> v;
int main(){
ios_base::sync_with_stdio(0),cin.tie(0);
cin >> N;
while(N--){
ll x;
cin >> x;
v.push_back(x);
}
for(int i = 1; i < v.size(); i++){
if(v[i] > v[i-1])
ans += (v[i] - v[i-1]);
}
cout << ans;
return 0;
}