#include "towers.h"
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
int n;
int v[maxn];
int dp[maxn];
void init(int N, std::vector<int> H) {
n = N;
for(int i = 1 ; i <= n ; i++)
v[i] = H[i - 1];
}
int max_towers(int L, int R, int D)
{
L++; R++;
int ans = 0;
for(int i = R ; i >= L ; i--)
{
dp[i] = 0;
int maxTower = v[i + 1];
for(int j = i + 2 ; j <= R ; j++)
{
if( v[i] <= maxTower - D && v[j] <= maxTower - D )
dp[i] = max( dp[i] , dp[j] );
maxTower = max( maxTower , v[j] );
}
dp[i]++;
ans = max( ans , dp[i] );
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4016 ms |
1060 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 |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
1 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
336 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 |
2 ms |
336 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 |
4 ms |
336 KB |
Output is correct |
21 |
Correct |
3 ms |
336 KB |
Output is correct |
22 |
Correct |
3 ms |
336 KB |
Output is correct |
23 |
Correct |
3 ms |
336 KB |
Output is correct |
24 |
Correct |
3 ms |
336 KB |
Output is correct |
25 |
Correct |
1 ms |
208 KB |
Output is correct |
26 |
Correct |
3 ms |
336 KB |
Output is correct |
27 |
Correct |
4 ms |
340 KB |
Output is correct |
28 |
Correct |
3 ms |
336 KB |
Output is correct |
29 |
Correct |
3 ms |
208 KB |
Output is correct |
30 |
Correct |
4 ms |
336 KB |
Output is correct |
31 |
Correct |
4 ms |
336 KB |
Output is correct |
32 |
Correct |
3 ms |
208 KB |
Output is correct |
33 |
Correct |
3 ms |
336 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 |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
1 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
336 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 |
2 ms |
336 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 |
4 ms |
336 KB |
Output is correct |
21 |
Correct |
3 ms |
336 KB |
Output is correct |
22 |
Correct |
3 ms |
336 KB |
Output is correct |
23 |
Correct |
3 ms |
336 KB |
Output is correct |
24 |
Correct |
3 ms |
336 KB |
Output is correct |
25 |
Correct |
1 ms |
208 KB |
Output is correct |
26 |
Correct |
3 ms |
336 KB |
Output is correct |
27 |
Correct |
4 ms |
340 KB |
Output is correct |
28 |
Correct |
3 ms |
336 KB |
Output is correct |
29 |
Correct |
3 ms |
208 KB |
Output is correct |
30 |
Correct |
4 ms |
336 KB |
Output is correct |
31 |
Correct |
4 ms |
336 KB |
Output is correct |
32 |
Correct |
3 ms |
208 KB |
Output is correct |
33 |
Correct |
3 ms |
336 KB |
Output is correct |
34 |
Correct |
3 ms |
208 KB |
Output is correct |
35 |
Correct |
3 ms |
208 KB |
Output is correct |
36 |
Correct |
308 ms |
976 KB |
Output is correct |
37 |
Correct |
1028 ms |
1444 KB |
Output is correct |
38 |
Correct |
226 ms |
1432 KB |
Output is correct |
39 |
Correct |
593 ms |
1392 KB |
Output is correct |
40 |
Correct |
195 ms |
1352 KB |
Output is correct |
41 |
Execution timed out |
4022 ms |
1736 KB |
Time limit exceeded |
42 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4078 ms |
1452 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4062 ms |
752 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 |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
1 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
336 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 |
2 ms |
336 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 |
4 ms |
336 KB |
Output is correct |
21 |
Correct |
3 ms |
336 KB |
Output is correct |
22 |
Correct |
3 ms |
336 KB |
Output is correct |
23 |
Correct |
3 ms |
336 KB |
Output is correct |
24 |
Correct |
3 ms |
336 KB |
Output is correct |
25 |
Correct |
1 ms |
208 KB |
Output is correct |
26 |
Correct |
3 ms |
336 KB |
Output is correct |
27 |
Correct |
4 ms |
340 KB |
Output is correct |
28 |
Correct |
3 ms |
336 KB |
Output is correct |
29 |
Correct |
3 ms |
208 KB |
Output is correct |
30 |
Correct |
4 ms |
336 KB |
Output is correct |
31 |
Correct |
4 ms |
336 KB |
Output is correct |
32 |
Correct |
3 ms |
208 KB |
Output is correct |
33 |
Correct |
3 ms |
336 KB |
Output is correct |
34 |
Correct |
3 ms |
208 KB |
Output is correct |
35 |
Correct |
3 ms |
208 KB |
Output is correct |
36 |
Correct |
308 ms |
976 KB |
Output is correct |
37 |
Correct |
1028 ms |
1444 KB |
Output is correct |
38 |
Correct |
226 ms |
1432 KB |
Output is correct |
39 |
Correct |
593 ms |
1392 KB |
Output is correct |
40 |
Correct |
195 ms |
1352 KB |
Output is correct |
41 |
Execution timed out |
4022 ms |
1736 KB |
Time limit exceeded |
42 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4016 ms |
1060 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |