Submission

Status:
[PP-SSSSSSSSSS]

Score: 0

User: Nightingale

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

Language: cpp

Time: 0.002 second

Submitted On: 2025-03-27 15:34:19

#include <bits/stdc++.h>
#define int long long
using namespace std;
int32_t main() 
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int a;
  cin >> a;
  int profit;
  int bestprof = 0;
  int mini = LLONG_MAX;
  for(int i=0;i<a;i++){
    int b;
    cin >> b;
    if(b<mini){
      mini = b;
    }else{
      profit = b-mini;
      if(profit>bestprof){
        bestprof = profit;
      }
    }
  }
  cout << bestprof;
}