Submission
Status:
[PPPPPPPPPPPPPPP]
Subtask/Task Score:
{100/100}
Score: 100
User: tha_smith
Problemset: จุดตัดบนกราฟ
Language: cpp
Time: 0.051 second
Submitted On: 2026-02-27 15:23:22
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
ios_base::sync_with_stdio(0),cin.tie(0);
ll N,prev;
map<ll,ll> m;
cin >> N >> prev;
for(ll i=1;i<N;i++) {
ll y;
cin >> y;
ll mn = min(prev,y);
ll mx = max(prev,y);
prev = y;
m[mn]++;
m[mx]--;
}
ll sum=0,ans=0;
for(auto[idx,cnt]:m) {
sum+=cnt;
ans=max(ans,sum);
}
cout << ans;
}