Submission

Status:
[PPPPP-SSSSSSSSS]

Score: 0

User: Nightingale

Problemset: จุดตัดบนกราฟ

Language: cpp

Time: 0.002 second

Submitted On: 2025-04-01 11:41:33

#include <bits/stdc++.h>
#define int long long
using namespace std;
int32_t main() 
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  unordered_map<int,int> stock;
  int best = 0;
  int a;
  cin >> a;
  int pre;
  cin >> pre;
  for(int i=1;i<a;i++){
    int b;
    cin >> b;
    if(b>pre){
      stock[pre]++;
      stock[b]--;
    }else{
      stock[b]++;
      stock[pre]--;
    }
    pre = b;
  }
  for(auto it=stock.begin();it!=stock.end();it++){
    if(best<it->second) best = it->second;
  }
  cout << best;
}