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>
#define int long long
using namespace std;
int ar[1000005];
int add[1000005];
vector<pair<int,int> >v;
int cnt=0;
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;cin>>n;
for(int i=1;i<=n;i++){
cin>>ar[i];
v.push_back({ar[i],i});
}
sort(v.begin(),v.end(),greater<pair<int,int>>());
int mx=0;
for(int i=0;i<n;){
auto x=v[i];
add[x.second]=1;
int temp=0;
if(add[x.second-1])temp++;
if(add[x.second+1])temp++;
if(temp==0)cnt++;
if(temp==2)cnt--;
i++;
while(i<n&&x.first==v[i].first){
auto x=v[i];
add[x.second]=1;
int temp=0;
if(add[x.second-1])temp++;
if(add[x.second+1])temp++;
if(temp==0)cnt++;
if(temp==2)cnt--;
i++;
}
mx=max(mx,cnt);
}
cout<<mx;
}
# | 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... |