#include "towers.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int N;
vector<int> H;
void init(int _N, vector<int> _H) {
N = _N;
H = _H;
}
int max_towers(int L, int R, int D) {
vector<int> dp(N, 1);
for (int i = L; i <= R; i++) {
int mx = 0;
for (int j = i - 1; j >= L; j--) {
if (H[j] + D <= mx && H[i] + D <= mx) {
dp[i] = max(dp[i], dp[j] + 1);
}
mx = max(mx, H[j]);
}
}
return *max_element(dp.begin(), dp.end());
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4049 ms |
996 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
3 ms |
208 KB |
Output is correct |
3 |
Correct |
2 ms |
208 KB |
Output is correct |
4 |
Correct |
2 ms |
336 KB |
Output is correct |
5 |
Correct |
2 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
2 ms |
208 KB |
Output is correct |
8 |
Correct |
1 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
208 KB |
Output is correct |
10 |
Correct |
1 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
208 KB |
Output is correct |
12 |
Correct |
0 ms |
208 KB |
Output is correct |
13 |
Correct |
1 ms |
208 KB |
Output is correct |
14 |
Correct |
1 ms |
208 KB |
Output is correct |
15 |
Correct |
1 ms |
208 KB |
Output is correct |
16 |
Correct |
5 ms |
208 KB |
Output is correct |
17 |
Correct |
1 ms |
208 KB |
Output is correct |
18 |
Correct |
1 ms |
208 KB |
Output is correct |
19 |
Correct |
1 ms |
208 KB |
Output is correct |
20 |
Correct |
7 ms |
312 KB |
Output is correct |
21 |
Correct |
7 ms |
208 KB |
Output is correct |
22 |
Correct |
7 ms |
208 KB |
Output is correct |
23 |
Correct |
3 ms |
208 KB |
Output is correct |
24 |
Correct |
4 ms |
208 KB |
Output is correct |
25 |
Correct |
1 ms |
208 KB |
Output is correct |
26 |
Correct |
6 ms |
208 KB |
Output is correct |
27 |
Correct |
6 ms |
208 KB |
Output is correct |
28 |
Correct |
4 ms |
208 KB |
Output is correct |
29 |
Correct |
5 ms |
208 KB |
Output is correct |
30 |
Correct |
8 ms |
208 KB |
Output is correct |
31 |
Correct |
7 ms |
208 KB |
Output is correct |
32 |
Correct |
3 ms |
324 KB |
Output is correct |
33 |
Correct |
3 ms |
208 KB |
Output is correct |
34 |
Correct |
3 ms |
208 KB |
Output is correct |
35 |
Correct |
3 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
3 ms |
208 KB |
Output is correct |
3 |
Correct |
2 ms |
208 KB |
Output is correct |
4 |
Correct |
2 ms |
336 KB |
Output is correct |
5 |
Correct |
2 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
2 ms |
208 KB |
Output is correct |
8 |
Correct |
1 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
208 KB |
Output is correct |
10 |
Correct |
1 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
208 KB |
Output is correct |
12 |
Correct |
0 ms |
208 KB |
Output is correct |
13 |
Correct |
1 ms |
208 KB |
Output is correct |
14 |
Correct |
1 ms |
208 KB |
Output is correct |
15 |
Correct |
1 ms |
208 KB |
Output is correct |
16 |
Correct |
5 ms |
208 KB |
Output is correct |
17 |
Correct |
1 ms |
208 KB |
Output is correct |
18 |
Correct |
1 ms |
208 KB |
Output is correct |
19 |
Correct |
1 ms |
208 KB |
Output is correct |
20 |
Correct |
7 ms |
312 KB |
Output is correct |
21 |
Correct |
7 ms |
208 KB |
Output is correct |
22 |
Correct |
7 ms |
208 KB |
Output is correct |
23 |
Correct |
3 ms |
208 KB |
Output is correct |
24 |
Correct |
4 ms |
208 KB |
Output is correct |
25 |
Correct |
1 ms |
208 KB |
Output is correct |
26 |
Correct |
6 ms |
208 KB |
Output is correct |
27 |
Correct |
6 ms |
208 KB |
Output is correct |
28 |
Correct |
4 ms |
208 KB |
Output is correct |
29 |
Correct |
5 ms |
208 KB |
Output is correct |
30 |
Correct |
8 ms |
208 KB |
Output is correct |
31 |
Correct |
7 ms |
208 KB |
Output is correct |
32 |
Correct |
3 ms |
324 KB |
Output is correct |
33 |
Correct |
3 ms |
208 KB |
Output is correct |
34 |
Correct |
3 ms |
208 KB |
Output is correct |
35 |
Correct |
3 ms |
208 KB |
Output is correct |
36 |
Correct |
532 ms |
1052 KB |
Output is correct |
37 |
Correct |
2152 ms |
1464 KB |
Output is correct |
38 |
Correct |
333 ms |
1460 KB |
Output is correct |
39 |
Correct |
791 ms |
1456 KB |
Output is correct |
40 |
Correct |
275 ms |
1468 KB |
Output is correct |
41 |
Execution timed out |
4035 ms |
1436 KB |
Time limit exceeded |
42 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4010 ms |
1448 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4073 ms |
548 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
3 ms |
208 KB |
Output is correct |
3 |
Correct |
2 ms |
208 KB |
Output is correct |
4 |
Correct |
2 ms |
336 KB |
Output is correct |
5 |
Correct |
2 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
2 ms |
208 KB |
Output is correct |
8 |
Correct |
1 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
208 KB |
Output is correct |
10 |
Correct |
1 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
208 KB |
Output is correct |
12 |
Correct |
0 ms |
208 KB |
Output is correct |
13 |
Correct |
1 ms |
208 KB |
Output is correct |
14 |
Correct |
1 ms |
208 KB |
Output is correct |
15 |
Correct |
1 ms |
208 KB |
Output is correct |
16 |
Correct |
5 ms |
208 KB |
Output is correct |
17 |
Correct |
1 ms |
208 KB |
Output is correct |
18 |
Correct |
1 ms |
208 KB |
Output is correct |
19 |
Correct |
1 ms |
208 KB |
Output is correct |
20 |
Correct |
7 ms |
312 KB |
Output is correct |
21 |
Correct |
7 ms |
208 KB |
Output is correct |
22 |
Correct |
7 ms |
208 KB |
Output is correct |
23 |
Correct |
3 ms |
208 KB |
Output is correct |
24 |
Correct |
4 ms |
208 KB |
Output is correct |
25 |
Correct |
1 ms |
208 KB |
Output is correct |
26 |
Correct |
6 ms |
208 KB |
Output is correct |
27 |
Correct |
6 ms |
208 KB |
Output is correct |
28 |
Correct |
4 ms |
208 KB |
Output is correct |
29 |
Correct |
5 ms |
208 KB |
Output is correct |
30 |
Correct |
8 ms |
208 KB |
Output is correct |
31 |
Correct |
7 ms |
208 KB |
Output is correct |
32 |
Correct |
3 ms |
324 KB |
Output is correct |
33 |
Correct |
3 ms |
208 KB |
Output is correct |
34 |
Correct |
3 ms |
208 KB |
Output is correct |
35 |
Correct |
3 ms |
208 KB |
Output is correct |
36 |
Correct |
532 ms |
1052 KB |
Output is correct |
37 |
Correct |
2152 ms |
1464 KB |
Output is correct |
38 |
Correct |
333 ms |
1460 KB |
Output is correct |
39 |
Correct |
791 ms |
1456 KB |
Output is correct |
40 |
Correct |
275 ms |
1468 KB |
Output is correct |
41 |
Execution timed out |
4035 ms |
1436 KB |
Time limit exceeded |
42 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4049 ms |
996 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |