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 MAX 1000005
using namespace std;
struct str
{
int val;
int ind;
}v[MAX];
bool sol[MAX];
bool crt(str a,str b)
{
return a.val<b.val;
}
int main()
{
int n;
cin>>n;
int i;
for(i=1;i<=n;++i)
{
cin>>v[i].val;
v[i].ind=i;
sol[i]=1;
}
sort(v+1,v+n+1,crt);
int maxim=1;
int act=1;
for(i=1;i<=n;)
{
int j=i;
while(j<n && v[j].val==v[j+1].val)
++j;
for(;i<=j;++i)
{
int ind=v[i].ind;
if(sol[ind-1] && sol[ind+1])
++act;
if(!sol[ind-1] && !sol[ind+1])
--act;
sol[ind]=0;
}
maxim=max(maxim,act);
}
cout<<maxim;
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... |