#include<iostream>
#include<algorithm>
using namespace std;
typedef pair<int,int>ii;
int N,a[1000000],ch=0,ans=-1;
ii b[1000000];
//0=land,1=no land
bool f[1000000]={};
int main(){
cin>>N;
for(int i=0;i<N;++i){
cin>>a[i];
b[i]={a[i],i};
}
sort(b,b+N);
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 |
520 KB |
Output is correct |
3 |
Correct |
2 ms |
528 KB |
Output is correct |
4 |
Correct |
2 ms |
552 KB |
Output is correct |
5 |
Correct |
2 ms |
624 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
2248 KB |
Output is correct |
2 |
Correct |
34 ms |
2492 KB |
Output is correct |
3 |
Correct |
34 ms |
2744 KB |
Output is correct |
4 |
Correct |
35 ms |
3000 KB |
Output is correct |
5 |
Correct |
36 ms |
3252 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
56 ms |
4344 KB |
Output is correct |
2 |
Correct |
43 ms |
4856 KB |
Output is correct |
3 |
Correct |
56 ms |
5876 KB |
Output is correct |
4 |
Correct |
55 ms |
6532 KB |
Output is correct |
5 |
Correct |
53 ms |
7432 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
602 ms |
28248 KB |
Output is correct |
2 |
Runtime error |
621 ms |
33792 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. |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
584 ms |
33792 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. |
2 |
Halted |
0 ms |
0 KB |
- |