#include <iostream>
#include <algorithm>
using namespace std;
const int Nmax=1000000;
struct island{
int h, t;
}e[Nmax*2+5];
int n, v[Nmax+1];
bool cmp(island a, island b){
return a.h<b.h;
}
int main()
{
cin>>n;
for (int i=0; i<n; i++)
cin>>v[i];
int mx=0, nris=0;
for (int i=0; i<n; i++){
if (mx<v[i])
mx=v[i];
if (v[i]<v[i-1] && v[i]<v[i+1]){
e[nris*2].t=1; e[nris*2].h=v[i];
e[nris*2+1].t=-1; e[nris*2+1].h=mx;
mx=0;
nris++;
}
}
e[nris*2].t=-1; e[nris*2].h=mx;
sort(e, e+nris*2+1, cmp);
int crt=1, i=0; mx=1;
while(i<=nris*2){
while (e[i].h==e[i+1].h){
crt+=e[i].t;
i++;
}
crt+=e[i].t;
if (crt>mx)
mx=crt;
i++;
}
cout<<mx;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
316 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
324 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
19 ms |
1332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
39 ms |
2016 KB |
Output is correct |
2 |
Correct |
42 ms |
2000 KB |
Output is correct |
3 |
Incorrect |
48 ms |
2012 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
425 ms |
18744 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
450 ms |
18176 KB |
Output is correct |
2 |
Correct |
453 ms |
18188 KB |
Output is correct |
3 |
Correct |
407 ms |
18056 KB |
Output is correct |
4 |
Incorrect |
194 ms |
12192 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |