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;
int main()
{
int n;
cin>>n;
vector<pair<int,int> >vps(n);
for(int i=0;i<n;i++){
cin>>vps[i].first;
vps[i].second=i;
}
sort(vps.begin(),vps.end());
int vis[n]={0};
int mx=1;
int cr=0;
for(int i=n-1;i>=0;i--){
vis[vps[i].second]=1;
if((vps[i].second-1>=0&&vis[vps[i].second-1])&&(vps[i].second+1<n&&vis[vps[i].second+1]))
cr--;
else if((vps[i].second-1<0||!vis[vps[i].second-1])&&(vps[i].second+1>=n||!vis[vps[i].second+1]))
cr++;
if(i==0||vps[i-1].first!=vps[i].first)
mx=max(mx,cr);
}
cout<<mx<<'\n';
return 0;
}
/****
1
8 4
3 1
4 3
1 8
8 7
1
100 9
1 100
2 1
3 2
4 3
5 4
100 99
99 98
98 97
97 96
19 3 6
3 12 9
2000000000 1000000000 1000000000
3 1000000000 1000000000
*/
# | 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... |