Submission
Status:
[PPPPPPPPPPPPPPP]
Subtask/Task Score:
{100/100}
Score: 100
User: C12
Problemset: จุดตัดบนกราฟ
Language: cpp
Time: 0.063 second
Submitted On: 2026-03-08 00:04:30
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
map<int,int>sum;
int old,neww;
cin >> old;
for(int i = 1; i < n;i++){
cin >> neww;
if(sum.find(old) == sum.end()) sum[old] = 0;
if(sum.find(neww) == sum.end()) sum[neww] = 0;
if(old > neww){
sum[old]--;
sum[neww]++;
}
else{
sum[old]++;
sum[neww]--;
}
old = neww;
}
int cnt = 0;
int mx = 0;
for(auto x:sum){
cnt += x.second;
// cout << x.second << '\n';
mx = max(mx,cnt);
}
cout << mx;
return 0;
}