Submission

Status:

[PP-SSSSSSSSSS]

Subtask/Task Score:

{0/100}

Score: 0

User: sorrkub

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

Language: cpp

Time: 0.002 second

Submitted On: 2026-02-08 21:44:35

#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;
const int MAX = 1e9+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=-1;
    for(int i=0;i<n;i++){
        if(vec[i]<minn){
            minn = vec[i];
        }
        else{
            maxx = max(maxx , vec[i]-minn);
        }
    }
    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!
*/