#include <iostream>
#include <vector>
#include <set>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <complex>
#include <stack>
#include <set>
#define FOR(i,n) for (int i = 0;i<n;i++)
#define FORE(i, a, b) for (int i = a;i<= b;i++)
#define ll long long int
#define ff first
#define ss second
#define ii pair<int,int>
#define pb push_back
#define mp make_pair
using namespace std;
int* arr;
int N;
// sl == sealevel
int query(int sl){
int cnt = 0;
FOR(i,N){
if(i == 0){
if(arr[i] > sl){
cnt++;
}
}else{
if(arr[i] > sl){
if(arr[i-1] <= sl)cnt++;
}
}
}
return cnt;
}
int gw(int nn,int *H){
N = nn;
ii crdcmprs[N];
FOR(i,N)crdcmprs[i].ff = H[i],crdcmprs[i].ss = i;
sort(crdcmprs,crdcmprs+N);
arr = new int[N];
FOR(i,N)arr[crdcmprs[i].ss] = crdcmprs[i].ff;
int mx = 0;
FOR(i,min(crdcmprs[N-1].ff+1,N+2)){
mx = max(mx,query(i));
}
//cout << mx << endl;
return mx;
}
int main(){
int n;
cin >> n;
int h[n];
FOR(i,n)cin >> h[i];
cout << gw(n,h) << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
35 ms |
1960 KB |
Output is correct |
2 |
Correct |
36 ms |
2076 KB |
Output is correct |
3 |
Correct |
37 ms |
1912 KB |
Output is correct |
4 |
Correct |
36 ms |
2040 KB |
Output is correct |
5 |
Correct |
36 ms |
2040 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1079 ms |
1924 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1070 ms |
16000 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1065 ms |
16048 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |