Submission

Status:

[PPPPPPPPPPPPP]

Subtask/Task Score:

{100/100}

Score: 100

User: sorrkub

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

Language: cpp

Time: 0.008 second

Submitted On: 2026-02-08 21:53:48

#include<bits/stdc++.h>
using namespace std;
typedef long long ll; typedef pair<long long ,long long> pll; typedef pair<long long, pair<long long , long long >> plpll;
#define int long long
const int MAX = 1e17+7;
int dx[8] = {0,0,-1,1,-1,1,-1,1} , dy[8] = {1,-1,0,0,1,-1,1,-1};
#define F first
#define S second
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL);

int n;

void solve(){
    cin>>n;
    vector<int> vec(n);
    for(int i=0;i<n;i++){
        cin>>vec[i];
    }
    int minn = MAX,maxx=0;
    for(int i=0;i<n-1;i++){
        if(vec[i+1] > vec[i]){
            maxx += vec[i+1]-vec[i];
        }
    }
    cout<<maxx;
}

signed main(){
    FAST_IO
    int q=1;
    //cin>>q;
    while(q--){
        solve();
    }
    return 0;
}






/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \|     |//  `.
            /  \|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
              pass System Test!
*/