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;
#define int long long
const int maxn=1e6+10;
const int mod=1e9+7;
struct st
{
int val;
int idx;
}v[maxn];
bool vis[maxn];
bool S(st x,st y)
{
return x.val<y.val;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
///freopen("prieteni.in","r",stdin);
///freopen("prieteni.out","w",stdout);
int n;
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>v[i].val;
v[i].idx=i;
}
vis[0]=vis[n+1]=1;
sort(v+1,v+n+1,S);
int ans=1;
int sum=1;
int i=1;
while(i<=n)
{
int j=i-1;
while(j+1<=n && v[j+1].val==v[i].val)
{
j++;
}
for(;i<=j;i++)
{
int ind=v[i].idx;
if(vis[ind-1]==1 && vis[ind+1]==1)
{
sum--;
}
if(!vis[ind-1] && !vis[ind+1])
{
sum++;
}
vis[ind]=1;
}
ans=max(ans,sum);
}
cout<<ans<<endl;
return 0;
}
# | 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... |