#include "towers.h"
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
int n;
vi H, Hord;
map<int, int> NorMap;
void init(int n, vi H0) {
::n = n;
H = H0;
Hord = H;
sort(Hord.begin(), Hord.end());
Hord.resize(unique(Hord.begin(), Hord.end()) - Hord.begin());
for(int i = 0; i < (int)Hord.size(); ++i)
NorMap[Hord[i]] = i;
}
int max_towers(int l, int r, int D) {
vi DP(n, 1);
int re = 0;
for (int i = l; i <= r; ++i) {
int ma = 0;
for (int j = i + 2; j <= r; ++j) {
ma = max(ma, H[j - 1]);
if(ma >= H[j] + D && ma >= H[i] + D) {
DP[j] = max(DP[j], DP[i] + 1);
}
}
re = max(re, DP[i]);
}
return re;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4048 ms |
3948 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
344 KB |
Output is correct |
18 |
Correct |
0 ms |
344 KB |
Output is correct |
19 |
Correct |
0 ms |
344 KB |
Output is correct |
20 |
Correct |
2 ms |
344 KB |
Output is correct |
21 |
Correct |
2 ms |
344 KB |
Output is correct |
22 |
Correct |
2 ms |
344 KB |
Output is correct |
23 |
Correct |
2 ms |
344 KB |
Output is correct |
24 |
Correct |
2 ms |
344 KB |
Output is correct |
25 |
Correct |
0 ms |
344 KB |
Output is correct |
26 |
Correct |
3 ms |
344 KB |
Output is correct |
27 |
Correct |
2 ms |
344 KB |
Output is correct |
28 |
Correct |
2 ms |
344 KB |
Output is correct |
29 |
Correct |
2 ms |
344 KB |
Output is correct |
30 |
Correct |
2 ms |
344 KB |
Output is correct |
31 |
Correct |
2 ms |
344 KB |
Output is correct |
32 |
Correct |
1 ms |
344 KB |
Output is correct |
33 |
Correct |
2 ms |
344 KB |
Output is correct |
34 |
Correct |
1 ms |
344 KB |
Output is correct |
35 |
Correct |
2 ms |
548 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
344 KB |
Output is correct |
18 |
Correct |
0 ms |
344 KB |
Output is correct |
19 |
Correct |
0 ms |
344 KB |
Output is correct |
20 |
Correct |
2 ms |
344 KB |
Output is correct |
21 |
Correct |
2 ms |
344 KB |
Output is correct |
22 |
Correct |
2 ms |
344 KB |
Output is correct |
23 |
Correct |
2 ms |
344 KB |
Output is correct |
24 |
Correct |
2 ms |
344 KB |
Output is correct |
25 |
Correct |
0 ms |
344 KB |
Output is correct |
26 |
Correct |
3 ms |
344 KB |
Output is correct |
27 |
Correct |
2 ms |
344 KB |
Output is correct |
28 |
Correct |
2 ms |
344 KB |
Output is correct |
29 |
Correct |
2 ms |
344 KB |
Output is correct |
30 |
Correct |
2 ms |
344 KB |
Output is correct |
31 |
Correct |
2 ms |
344 KB |
Output is correct |
32 |
Correct |
1 ms |
344 KB |
Output is correct |
33 |
Correct |
2 ms |
344 KB |
Output is correct |
34 |
Correct |
1 ms |
344 KB |
Output is correct |
35 |
Correct |
2 ms |
548 KB |
Output is correct |
36 |
Correct |
200 ms |
4440 KB |
Output is correct |
37 |
Correct |
1105 ms |
6680 KB |
Output is correct |
38 |
Correct |
135 ms |
6684 KB |
Output is correct |
39 |
Correct |
472 ms |
6608 KB |
Output is correct |
40 |
Correct |
111 ms |
6612 KB |
Output is correct |
41 |
Correct |
2765 ms |
6684 KB |
Output is correct |
42 |
Correct |
30 ms |
6600 KB |
Output is correct |
43 |
Correct |
742 ms |
6680 KB |
Output is correct |
44 |
Correct |
74 ms |
6644 KB |
Output is correct |
45 |
Correct |
22 ms |
6608 KB |
Output is correct |
46 |
Correct |
20 ms |
6608 KB |
Output is correct |
47 |
Correct |
609 ms |
6688 KB |
Output is correct |
48 |
Correct |
241 ms |
6604 KB |
Output is correct |
49 |
Correct |
51 ms |
6684 KB |
Output is correct |
50 |
Correct |
218 ms |
6600 KB |
Output is correct |
51 |
Correct |
466 ms |
6608 KB |
Output is correct |
52 |
Execution timed out |
4038 ms |
6608 KB |
Time limit exceeded |
53 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4035 ms |
6644 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4057 ms |
1900 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
344 KB |
Output is correct |
18 |
Correct |
0 ms |
344 KB |
Output is correct |
19 |
Correct |
0 ms |
344 KB |
Output is correct |
20 |
Correct |
2 ms |
344 KB |
Output is correct |
21 |
Correct |
2 ms |
344 KB |
Output is correct |
22 |
Correct |
2 ms |
344 KB |
Output is correct |
23 |
Correct |
2 ms |
344 KB |
Output is correct |
24 |
Correct |
2 ms |
344 KB |
Output is correct |
25 |
Correct |
0 ms |
344 KB |
Output is correct |
26 |
Correct |
3 ms |
344 KB |
Output is correct |
27 |
Correct |
2 ms |
344 KB |
Output is correct |
28 |
Correct |
2 ms |
344 KB |
Output is correct |
29 |
Correct |
2 ms |
344 KB |
Output is correct |
30 |
Correct |
2 ms |
344 KB |
Output is correct |
31 |
Correct |
2 ms |
344 KB |
Output is correct |
32 |
Correct |
1 ms |
344 KB |
Output is correct |
33 |
Correct |
2 ms |
344 KB |
Output is correct |
34 |
Correct |
1 ms |
344 KB |
Output is correct |
35 |
Correct |
2 ms |
548 KB |
Output is correct |
36 |
Correct |
200 ms |
4440 KB |
Output is correct |
37 |
Correct |
1105 ms |
6680 KB |
Output is correct |
38 |
Correct |
135 ms |
6684 KB |
Output is correct |
39 |
Correct |
472 ms |
6608 KB |
Output is correct |
40 |
Correct |
111 ms |
6612 KB |
Output is correct |
41 |
Correct |
2765 ms |
6684 KB |
Output is correct |
42 |
Correct |
30 ms |
6600 KB |
Output is correct |
43 |
Correct |
742 ms |
6680 KB |
Output is correct |
44 |
Correct |
74 ms |
6644 KB |
Output is correct |
45 |
Correct |
22 ms |
6608 KB |
Output is correct |
46 |
Correct |
20 ms |
6608 KB |
Output is correct |
47 |
Correct |
609 ms |
6688 KB |
Output is correct |
48 |
Correct |
241 ms |
6604 KB |
Output is correct |
49 |
Correct |
51 ms |
6684 KB |
Output is correct |
50 |
Correct |
218 ms |
6600 KB |
Output is correct |
51 |
Correct |
466 ms |
6608 KB |
Output is correct |
52 |
Execution timed out |
4038 ms |
6608 KB |
Time limit exceeded |
53 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4048 ms |
3948 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |