Submission
Status:
[PPPPP-SSSSSSSSS]
Subtask/Task Score:
{0/100}
Score: 0
User: Zonezonee
Problemset: จุดตัดบนกราฟ
Language: cpp
Time: 0.002 second
Submitted On: 2026-01-16 19:09:37
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+10;
int sweep[2*N], a[N], t[N];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
for(int i = 1; i <= n; ++i) cin >> a[i], t[i] = a[i];
sort(t+1, t+n+1);
for(int i = 1; i <= n; ++i){
a[i] = lower_bound(t+1, t+1+n, a[i])-t;
a[i] = 2*a[i]-1;
}
for(int i = 1; i < n; ++i){
int l = min(a[i], a[i+1]), r = max(a[i], a[i+1]);
sweep[l]++;
sweep[r+1]--;
}
int ans = 0;
for(int i = 1; i <= 2*n; ++i) ans = max(ans, sweep[i]);
cout << ans << '\n';
}