Submission

Status:

[PPPPPPPPPPPPP]

Subtask/Task Score:

{100/100}

Score: 100

User: Gump2011

Problemset: ซื้อขายหุ้นซีเค

Language: cpp

Time: 0.009 second

Submitted On: 2026-03-08 22:21:28

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;

    vector<long long> p(n);
    for(int i=0;i<n;i++) cin >> p[i];

    long long ans = 0;

    for(int i=0;i<n-1;i++){
        if(p[i+1] > p[i]){
            ans += p[i+1] - p[i];
        }
    }

    cout << ans;

    return 0;
}