#include "towers.h"
#include <bits/stdc++.h>
using namespace std;
const int maxl = 20;
const int maxn = 100010;
const int inf = 1000000010;
int n;
int peak;
int v[maxn];
void init(int N, vector<int> H) {
n = N;
for(int i = 1 ; i <= n ; i++)
v[i] = H[i - 1];
for(int i = 1 ; i <= n ; i++)
if( v[i - 1] < v[i] && v[i] > v[i + 1] ) peak = i;
}
int max_towers(int L, int R, int D)
{
L++; R++;
if( peak <= L || R <= peak )
return 1;
if( v[L] <= v[peak] - D && v[R] <= v[peak] - D )
return 2;
return 1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
419 ms |
976 KB |
Output is correct |
2 |
Correct |
794 ms |
1360 KB |
Output is correct |
3 |
Correct |
906 ms |
1456 KB |
Output is correct |
4 |
Correct |
877 ms |
1452 KB |
Output is correct |
5 |
Correct |
913 ms |
1440 KB |
Output is correct |
6 |
Correct |
614 ms |
1452 KB |
Output is correct |
7 |
Correct |
820 ms |
1468 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
1st lines differ - on the 1st token, expected: '13', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
1st lines differ - on the 1st token, expected: '13', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
627 ms |
1452 KB |
1st lines differ - on the 1st token, expected: '11903', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
274 ms |
464 KB |
1st lines differ - on the 1st token, expected: '7197', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
1st lines differ - on the 1st token, expected: '13', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
419 ms |
976 KB |
Output is correct |
2 |
Correct |
794 ms |
1360 KB |
Output is correct |
3 |
Correct |
906 ms |
1456 KB |
Output is correct |
4 |
Correct |
877 ms |
1452 KB |
Output is correct |
5 |
Correct |
913 ms |
1440 KB |
Output is correct |
6 |
Correct |
614 ms |
1452 KB |
Output is correct |
7 |
Correct |
820 ms |
1468 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
1 ms |
208 KB |
Output is correct |
11 |
Incorrect |
0 ms |
208 KB |
1st lines differ - on the 1st token, expected: '13', found: '1' |
12 |
Halted |
0 ms |
0 KB |
- |