Submission
Status:
[PPPPPPPPPPPPPPP]
Subtask/Task Score:
{100/100}
Score: 100
User: achinhchin
Problemset: จุดตัดบนกราฟ
Language: cpp
Time: 0.064 second
Submitted On: 2026-02-26 03:20:25
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#define f first
#define s second
#define fr front()
#define bg begin()
#define en end()
using namespace std;
typedef long long l;
typedef pair<l,l> pl;
typedef pair<l,pair<l,l>> ppl;
typedef vector<l> vl;
typedef vector<pair<l,l>> vpl;
typedef map<l,l> ml;
const l LLM=1e18;
ml M;
l n,tl,t,sm,mx;
int main(){
cin.tie(nullptr)->sync_with_stdio(0);
cin>>n>>tl;n--;M[tl=(tl-1)*2]++,M[tl+1]--;
while(n--)cin>>t,t=(t-1)*2,(t>tl?(M[tl+1]++,M[t+1]--):(M[t]++,M[tl]--)),tl=t;
for(auto i:M)sm+=i.s,mx=max(mx,sm);
cout<<mx;
}