Submission
Status:
[PPPPPPPPPPPPP]
Subtask/Task Score:
{100/100}
Score: 100
User: 12345678
Problemset: ซื้อขายหุ้นซีเค
Language: cpp
Time: 0.009 second
Submitted On: 2025-11-27 21:16:41
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int nx=1e5+5;
ll n, p[nx], sm;
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n;
for (int i=1; i<=n; i++) cin>>p[i];
for (int i=2; i<=n; i++) sm+=max(p[i]-p[i-1], 0ll);
cout<<sm;
}