#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,v+n,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 |
4440 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
18 ms |
4444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
178 ms |
26324 KB |
Output is correct |
2 |
Incorrect |
178 ms |
26184 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
184 ms |
25548 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |