#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef pair<int,int>ii;
int N,a[1000000],ch=0,ans=-1;
vector<ii>b;
//0=land,1=no land
bool f[1000000]={};
int main(){
cin>>N;
for(int i=0;i<N;++i){
cin>>a[i];
b.push_back({a[i],i});
}
sort(b.begin(),b.end());
if(b[0].first>0)ans=1;
for(int i=0;i<N;++i){
int x=b[i].second;
if(x!=0)ch+=(f[x]==f[x-1]?1:-1);
if(x!=N-1)ch+=(f[x]==f[x+1]?1:-1);
f[x]=1;
if((i==N-1)||(b[i].first!=b[i+1].first)){
int isl;
if(f[0]){
//011223344...
isl=ch/2+ch%2;
}else{
//112233445...
isl=ch/2+1;
}
ans=max(ans,isl);
}
}
cout<<ans<<'\n';return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
452 KB |
Output is correct |
4 |
Correct |
2 ms |
452 KB |
Output is correct |
5 |
Correct |
3 ms |
596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
35 ms |
1900 KB |
Output is correct |
2 |
Correct |
39 ms |
1944 KB |
Output is correct |
3 |
Correct |
38 ms |
2020 KB |
Output is correct |
4 |
Correct |
37 ms |
2020 KB |
Output is correct |
5 |
Correct |
35 ms |
2020 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
57 ms |
2020 KB |
Output is correct |
2 |
Correct |
45 ms |
2048 KB |
Output is correct |
3 |
Correct |
57 ms |
2048 KB |
Output is correct |
4 |
Correct |
59 ms |
2048 KB |
Output is correct |
5 |
Correct |
56 ms |
2048 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
635 ms |
13472 KB |
Output is correct |
2 |
Correct |
632 ms |
13504 KB |
Output is correct |
3 |
Correct |
614 ms |
13656 KB |
Output is correct |
4 |
Correct |
616 ms |
13656 KB |
Output is correct |
5 |
Correct |
596 ms |
13656 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
613 ms |
13656 KB |
Output is correct |
2 |
Correct |
614 ms |
22404 KB |
Output is correct |
3 |
Correct |
611 ms |
30980 KB |
Output is correct |
4 |
Runtime error |
371 ms |
33768 KB |
Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience. |
5 |
Halted |
0 ms |
0 KB |
- |