Submission
Status:
[PPPPPPPPPPPPP]
Score: 100
User: Dormon
Problemset: ซื้อขายหุ้นซีเค
Language: cpp
Time: 0.010 second
Submitted On: 2025-03-27 10:58:04
#include <iostream>
#include <vector>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
long long ans = 0ll;
cin >> n;
vector<long long> v(n + 1);
v[0] = 1e9;
for (int i = 1;i <= n;i++){
cin >> v[i];
ans += max(0ll, v[i] - v[i - 1]);
}
cout << ans << '\n';
}