#include <bits/stdc++.h>
using namespace std;
vector<int> height;
int N,k=0;
void init(int n,vector<int> H)
{
N=n;
height=H;
}
int max_towers(int l,int r,int d)
{
int res=1;
vector<int> dp(N,1);
for (int i=l;i<=r;i++)
{
int tower=height[i-1];
for (int j=i-2;j>=l;j--)
{
if (tower-d>=height[j]&&tower-d>=height[i])
dp[i]=max(dp[i],dp[j]+1);
tower=max(tower,height[j]);
}
res=max(dp[i],res);
}
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4045 ms |
1116 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 |
2 ms |
208 KB |
Output is correct |
3 |
Correct |
2 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 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 |
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 |
4 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 |
208 KB |
Output is correct |
21 |
Correct |
7 ms |
208 KB |
Output is correct |
22 |
Correct |
7 ms |
208 KB |
Output is correct |
23 |
Correct |
4 ms |
312 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 |
5 ms |
208 KB |
Output is correct |
28 |
Correct |
4 ms |
312 KB |
Output is correct |
29 |
Correct |
5 ms |
208 KB |
Output is correct |
30 |
Correct |
6 ms |
316 KB |
Output is correct |
31 |
Correct |
6 ms |
208 KB |
Output is correct |
32 |
Correct |
3 ms |
208 KB |
Output is correct |
33 |
Correct |
3 ms |
208 KB |
Output is correct |
34 |
Correct |
3 ms |
312 KB |
Output is correct |
35 |
Correct |
3 ms |
316 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
2 ms |
208 KB |
Output is correct |
3 |
Correct |
2 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 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 |
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 |
4 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 |
208 KB |
Output is correct |
21 |
Correct |
7 ms |
208 KB |
Output is correct |
22 |
Correct |
7 ms |
208 KB |
Output is correct |
23 |
Correct |
4 ms |
312 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 |
5 ms |
208 KB |
Output is correct |
28 |
Correct |
4 ms |
312 KB |
Output is correct |
29 |
Correct |
5 ms |
208 KB |
Output is correct |
30 |
Correct |
6 ms |
316 KB |
Output is correct |
31 |
Correct |
6 ms |
208 KB |
Output is correct |
32 |
Correct |
3 ms |
208 KB |
Output is correct |
33 |
Correct |
3 ms |
208 KB |
Output is correct |
34 |
Correct |
3 ms |
312 KB |
Output is correct |
35 |
Correct |
3 ms |
316 KB |
Output is correct |
36 |
Correct |
515 ms |
1048 KB |
Output is correct |
37 |
Correct |
2035 ms |
1488 KB |
Output is correct |
38 |
Correct |
333 ms |
1360 KB |
Output is correct |
39 |
Correct |
828 ms |
1468 KB |
Output is correct |
40 |
Correct |
246 ms |
1452 KB |
Output is correct |
41 |
Execution timed out |
4038 ms |
1444 KB |
Time limit exceeded |
42 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4043 ms |
1460 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4059 ms |
552 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 |
2 ms |
208 KB |
Output is correct |
3 |
Correct |
2 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 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 |
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 |
4 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 |
208 KB |
Output is correct |
21 |
Correct |
7 ms |
208 KB |
Output is correct |
22 |
Correct |
7 ms |
208 KB |
Output is correct |
23 |
Correct |
4 ms |
312 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 |
5 ms |
208 KB |
Output is correct |
28 |
Correct |
4 ms |
312 KB |
Output is correct |
29 |
Correct |
5 ms |
208 KB |
Output is correct |
30 |
Correct |
6 ms |
316 KB |
Output is correct |
31 |
Correct |
6 ms |
208 KB |
Output is correct |
32 |
Correct |
3 ms |
208 KB |
Output is correct |
33 |
Correct |
3 ms |
208 KB |
Output is correct |
34 |
Correct |
3 ms |
312 KB |
Output is correct |
35 |
Correct |
3 ms |
316 KB |
Output is correct |
36 |
Correct |
515 ms |
1048 KB |
Output is correct |
37 |
Correct |
2035 ms |
1488 KB |
Output is correct |
38 |
Correct |
333 ms |
1360 KB |
Output is correct |
39 |
Correct |
828 ms |
1468 KB |
Output is correct |
40 |
Correct |
246 ms |
1452 KB |
Output is correct |
41 |
Execution timed out |
4038 ms |
1444 KB |
Time limit exceeded |
42 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4045 ms |
1116 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |