#include "towers.h"
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define pii pair<int, int>
#define ff first
#define ss second
int a[200100];
int n;
int dp[200100];
void init(int N, vector<int> H) {
n = N;
for(int i=0; i<n; i++) a[i + 1] = H[i];
}
int max_towers(int L, int R, int D) {
L ++;
R ++;
dp[L-1] = 0;
for(int i=L; i<=R; i++){
int mx = 0;
dp[i] = 1;
for(int j=i-1; j>=L; j--){
//cout<<i<<' '<<j<<' '<<mx<<'\n';
if(mx - D >= a[i] and mx - D >= a[j]) dp[i] = max(dp[i], dp[j]+1);
mx = max(mx, a[j]);
}
}
int ans = 0;
for(int i=L; i<=R; i++){
ans = max(ans, dp[i]);
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4045 ms |
1132 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
2 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 |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
2 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
464 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
2 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 |
2 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
344 KB |
Output is correct |
18 |
Correct |
1 ms |
596 KB |
Output is correct |
19 |
Correct |
1 ms |
344 KB |
Output is correct |
20 |
Correct |
2 ms |
344 KB |
Output is correct |
21 |
Correct |
2 ms |
596 KB |
Output is correct |
22 |
Correct |
4 ms |
344 KB |
Output is correct |
23 |
Correct |
4 ms |
344 KB |
Output is correct |
24 |
Correct |
2 ms |
344 KB |
Output is correct |
25 |
Correct |
1 ms |
344 KB |
Output is correct |
26 |
Correct |
2 ms |
344 KB |
Output is correct |
27 |
Correct |
3 ms |
344 KB |
Output is correct |
28 |
Correct |
5 ms |
472 KB |
Output is correct |
29 |
Correct |
5 ms |
344 KB |
Output is correct |
30 |
Correct |
5 ms |
344 KB |
Output is correct |
31 |
Correct |
2 ms |
344 KB |
Output is correct |
32 |
Correct |
2 ms |
344 KB |
Output is correct |
33 |
Correct |
4 ms |
344 KB |
Output is correct |
34 |
Correct |
2 ms |
344 KB |
Output is correct |
35 |
Correct |
4 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
2 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 |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
2 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
464 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
2 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 |
2 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
344 KB |
Output is correct |
18 |
Correct |
1 ms |
596 KB |
Output is correct |
19 |
Correct |
1 ms |
344 KB |
Output is correct |
20 |
Correct |
2 ms |
344 KB |
Output is correct |
21 |
Correct |
2 ms |
596 KB |
Output is correct |
22 |
Correct |
4 ms |
344 KB |
Output is correct |
23 |
Correct |
4 ms |
344 KB |
Output is correct |
24 |
Correct |
2 ms |
344 KB |
Output is correct |
25 |
Correct |
1 ms |
344 KB |
Output is correct |
26 |
Correct |
2 ms |
344 KB |
Output is correct |
27 |
Correct |
3 ms |
344 KB |
Output is correct |
28 |
Correct |
5 ms |
472 KB |
Output is correct |
29 |
Correct |
5 ms |
344 KB |
Output is correct |
30 |
Correct |
5 ms |
344 KB |
Output is correct |
31 |
Correct |
2 ms |
344 KB |
Output is correct |
32 |
Correct |
2 ms |
344 KB |
Output is correct |
33 |
Correct |
4 ms |
344 KB |
Output is correct |
34 |
Correct |
2 ms |
344 KB |
Output is correct |
35 |
Correct |
4 ms |
344 KB |
Output is correct |
36 |
Correct |
254 ms |
1192 KB |
Output is correct |
37 |
Correct |
762 ms |
1604 KB |
Output is correct |
38 |
Correct |
165 ms |
1624 KB |
Output is correct |
39 |
Correct |
418 ms |
1608 KB |
Output is correct |
40 |
Correct |
104 ms |
1624 KB |
Output is correct |
41 |
Correct |
3415 ms |
1604 KB |
Output is correct |
42 |
Correct |
20 ms |
1624 KB |
Output is correct |
43 |
Correct |
1026 ms |
1496 KB |
Output is correct |
44 |
Correct |
85 ms |
1624 KB |
Output is correct |
45 |
Correct |
11 ms |
1624 KB |
Output is correct |
46 |
Correct |
10 ms |
1624 KB |
Output is correct |
47 |
Correct |
624 ms |
1612 KB |
Output is correct |
48 |
Correct |
261 ms |
1624 KB |
Output is correct |
49 |
Correct |
44 ms |
1624 KB |
Output is correct |
50 |
Correct |
293 ms |
1624 KB |
Output is correct |
51 |
Correct |
600 ms |
1624 KB |
Output is correct |
52 |
Execution timed out |
4062 ms |
1624 KB |
Time limit exceeded |
53 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4053 ms |
1624 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4057 ms |
1000 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
2 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 |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
2 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
464 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
2 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 |
2 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
344 KB |
Output is correct |
18 |
Correct |
1 ms |
596 KB |
Output is correct |
19 |
Correct |
1 ms |
344 KB |
Output is correct |
20 |
Correct |
2 ms |
344 KB |
Output is correct |
21 |
Correct |
2 ms |
596 KB |
Output is correct |
22 |
Correct |
4 ms |
344 KB |
Output is correct |
23 |
Correct |
4 ms |
344 KB |
Output is correct |
24 |
Correct |
2 ms |
344 KB |
Output is correct |
25 |
Correct |
1 ms |
344 KB |
Output is correct |
26 |
Correct |
2 ms |
344 KB |
Output is correct |
27 |
Correct |
3 ms |
344 KB |
Output is correct |
28 |
Correct |
5 ms |
472 KB |
Output is correct |
29 |
Correct |
5 ms |
344 KB |
Output is correct |
30 |
Correct |
5 ms |
344 KB |
Output is correct |
31 |
Correct |
2 ms |
344 KB |
Output is correct |
32 |
Correct |
2 ms |
344 KB |
Output is correct |
33 |
Correct |
4 ms |
344 KB |
Output is correct |
34 |
Correct |
2 ms |
344 KB |
Output is correct |
35 |
Correct |
4 ms |
344 KB |
Output is correct |
36 |
Correct |
254 ms |
1192 KB |
Output is correct |
37 |
Correct |
762 ms |
1604 KB |
Output is correct |
38 |
Correct |
165 ms |
1624 KB |
Output is correct |
39 |
Correct |
418 ms |
1608 KB |
Output is correct |
40 |
Correct |
104 ms |
1624 KB |
Output is correct |
41 |
Correct |
3415 ms |
1604 KB |
Output is correct |
42 |
Correct |
20 ms |
1624 KB |
Output is correct |
43 |
Correct |
1026 ms |
1496 KB |
Output is correct |
44 |
Correct |
85 ms |
1624 KB |
Output is correct |
45 |
Correct |
11 ms |
1624 KB |
Output is correct |
46 |
Correct |
10 ms |
1624 KB |
Output is correct |
47 |
Correct |
624 ms |
1612 KB |
Output is correct |
48 |
Correct |
261 ms |
1624 KB |
Output is correct |
49 |
Correct |
44 ms |
1624 KB |
Output is correct |
50 |
Correct |
293 ms |
1624 KB |
Output is correct |
51 |
Correct |
600 ms |
1624 KB |
Output is correct |
52 |
Execution timed out |
4062 ms |
1624 KB |
Time limit exceeded |
53 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4045 ms |
1132 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |