#include<bits/stdc++.h>
#define MAXN 100007
using namespace std;
int n,h[MAXN],maxh;
int dp[MAXN],ans;
void init(int N,vector<int> H){
n=N;
for(int i=1;i<=n;i++){
h[i]=H[i-1];
}
}
int max_towers(int L, int R, int D){
ans=0; L++; R++;
for(int i=L;i<=R;i++){
maxh=0; dp[i]=1;
for(int f=i-1;f>=L;f--){
if(h[f]<=maxh-D and h[i]<=maxh-D){
dp[i]=max(dp[i],dp[f]+1);
}
maxh=max(maxh,h[f]);
}
ans=max(ans,dp[i]);
}
return ans;
}
/*
int main(){
init(7, {10, 20, 60, 40, 50, 30, 70});
cout<<max_towers(1,5,10)<<"\n";
cout<<max_towers(0, 6, 17)<<"\n";
}
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
4006 ms |
1092 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
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 |
2 ms |
208 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
0 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 |
0 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 |
336 KB |
Output is correct |
20 |
Correct |
3 ms |
208 KB |
Output is correct |
21 |
Correct |
3 ms |
336 KB |
Output is correct |
22 |
Correct |
3 ms |
236 KB |
Output is correct |
23 |
Correct |
3 ms |
336 KB |
Output is correct |
24 |
Correct |
5 ms |
332 KB |
Output is correct |
25 |
Correct |
1 ms |
208 KB |
Output is correct |
26 |
Correct |
3 ms |
336 KB |
Output is correct |
27 |
Correct |
3 ms |
208 KB |
Output is correct |
28 |
Correct |
3 ms |
336 KB |
Output is correct |
29 |
Correct |
3 ms |
208 KB |
Output is correct |
30 |
Correct |
3 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 |
336 KB |
Output is correct |
35 |
Correct |
3 ms |
336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
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 |
2 ms |
208 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
0 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 |
0 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 |
336 KB |
Output is correct |
20 |
Correct |
3 ms |
208 KB |
Output is correct |
21 |
Correct |
3 ms |
336 KB |
Output is correct |
22 |
Correct |
3 ms |
236 KB |
Output is correct |
23 |
Correct |
3 ms |
336 KB |
Output is correct |
24 |
Correct |
5 ms |
332 KB |
Output is correct |
25 |
Correct |
1 ms |
208 KB |
Output is correct |
26 |
Correct |
3 ms |
336 KB |
Output is correct |
27 |
Correct |
3 ms |
208 KB |
Output is correct |
28 |
Correct |
3 ms |
336 KB |
Output is correct |
29 |
Correct |
3 ms |
208 KB |
Output is correct |
30 |
Correct |
3 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 |
336 KB |
Output is correct |
35 |
Correct |
3 ms |
336 KB |
Output is correct |
36 |
Correct |
267 ms |
976 KB |
Output is correct |
37 |
Correct |
1862 ms |
1452 KB |
Output is correct |
38 |
Correct |
281 ms |
1444 KB |
Output is correct |
39 |
Correct |
822 ms |
1448 KB |
Output is correct |
40 |
Correct |
151 ms |
1456 KB |
Output is correct |
41 |
Execution timed out |
4072 ms |
1352 KB |
Time limit exceeded |
42 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
4027 ms |
1452 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
4067 ms |
560 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
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 |
2 ms |
208 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
0 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 |
0 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 |
336 KB |
Output is correct |
20 |
Correct |
3 ms |
208 KB |
Output is correct |
21 |
Correct |
3 ms |
336 KB |
Output is correct |
22 |
Correct |
3 ms |
236 KB |
Output is correct |
23 |
Correct |
3 ms |
336 KB |
Output is correct |
24 |
Correct |
5 ms |
332 KB |
Output is correct |
25 |
Correct |
1 ms |
208 KB |
Output is correct |
26 |
Correct |
3 ms |
336 KB |
Output is correct |
27 |
Correct |
3 ms |
208 KB |
Output is correct |
28 |
Correct |
3 ms |
336 KB |
Output is correct |
29 |
Correct |
3 ms |
208 KB |
Output is correct |
30 |
Correct |
3 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 |
336 KB |
Output is correct |
35 |
Correct |
3 ms |
336 KB |
Output is correct |
36 |
Correct |
267 ms |
976 KB |
Output is correct |
37 |
Correct |
1862 ms |
1452 KB |
Output is correct |
38 |
Correct |
281 ms |
1444 KB |
Output is correct |
39 |
Correct |
822 ms |
1448 KB |
Output is correct |
40 |
Correct |
151 ms |
1456 KB |
Output is correct |
41 |
Execution timed out |
4072 ms |
1352 KB |
Time limit exceeded |
42 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
4006 ms |
1092 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |