#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
448 KB |
Output is correct |
3 |
Correct |
2 ms |
608 KB |
Output is correct |
4 |
Correct |
2 ms |
636 KB |
Output is correct |
5 |
Correct |
2 ms |
636 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
34 ms |
2172 KB |
Output is correct |
2 |
Correct |
34 ms |
2388 KB |
Output is correct |
3 |
Correct |
37 ms |
2660 KB |
Output is correct |
4 |
Correct |
35 ms |
2848 KB |
Output is correct |
5 |
Correct |
37 ms |
3220 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
58 ms |
3984 KB |
Output is correct |
2 |
Correct |
43 ms |
4692 KB |
Output is correct |
3 |
Correct |
56 ms |
5468 KB |
Output is correct |
4 |
Correct |
57 ms |
6308 KB |
Output is correct |
5 |
Correct |
55 ms |
7140 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
618 ms |
25820 KB |
Output is correct |
2 |
Correct |
615 ms |
25932 KB |
Output is correct |
3 |
Runtime error |
610 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. |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
608 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 |
- |