This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
const int mx=1e6+50;
typedef long long ll;
int inf=1e9+10;
const int mod=1e9+7;
ll n,m,k;
vector<pair<int,int>>v;
bool vis[mx];
ll ans=0;
int main(){
cin>>n;
for(int i=1;i<=n;i++){
int x;cin>>x;
v.push_back({x,i});
}
sort(v.rbegin(),v.rend());
int cur=0;
int ans=0;
for(ll i=0;i<n;i++){
cur++;
ll me=v[i].second;
vis[me]=1;
if((vis[me+1])){
cur--;
}
if(vis[me-1]){
cur--;
}
if(i==n-1||v[me+1].first!=v[me].first){
ans=max(ans,cur);
}
// cout<<cur;
}
cout<<ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |