#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;
}
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 |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
4444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
16 ms |
4444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
167 ms |
16976 KB |
Output is correct |
2 |
Incorrect |
168 ms |
16860 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
174 ms |
16980 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |