#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 100, K = 20;
bool case2 = 1;
int k, dp[N], n;
vector<int> A;
void init(int NN, std::vector<int> a){
n = NN;
if(n > 2000) case2 = 0;
k = max_element(a.begin(), a.end()) - a.begin();
A = a;
}
int max_towers(int L, int R, int D){
if(!case2){
if(R <= k || L >= k) return 1;
if(A[L] <= A[k] - D && A[R] <= A[k] - D) return 2;
return 1;
}
for(int i = 0; i < n; ++i) dp[i] = 1;
for(int i = L + 2; i <= R; ++i){
int mx = A[i - 1];
for(int j = i - 2; j >= L; --j){
if(mx - D >= A[i] && mx - D >= A[j]) dp[i] = max(dp[i], dp[j] + 1);
mx = max(mx, A[j]);
}
}
return *max_element(dp + L, dp + R + 1);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
341 ms |
920 KB |
Output is correct |
2 |
Correct |
777 ms |
1448 KB |
Output is correct |
3 |
Correct |
802 ms |
1356 KB |
Output is correct |
4 |
Correct |
736 ms |
1440 KB |
Output is correct |
5 |
Correct |
780 ms |
1488 KB |
Output is correct |
6 |
Correct |
901 ms |
1352 KB |
Output is correct |
7 |
Correct |
609 ms |
1432 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
208 KB |
Output is correct |
10 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
3 ms |
208 KB |
Output is correct |
3 |
Correct |
2 ms |
336 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 |
320 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 |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
208 KB |
Output is correct |
12 |
Correct |
1 ms |
208 KB |
Output is correct |
13 |
Correct |
1 ms |
208 KB |
Output is correct |
14 |
Correct |
2 ms |
336 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 |
336 KB |
Output is correct |
19 |
Correct |
1 ms |
208 KB |
Output is correct |
20 |
Correct |
8 ms |
336 KB |
Output is correct |
21 |
Correct |
7 ms |
208 KB |
Output is correct |
22 |
Correct |
7 ms |
332 KB |
Output is correct |
23 |
Correct |
4 ms |
208 KB |
Output is correct |
24 |
Correct |
4 ms |
208 KB |
Output is correct |
25 |
Correct |
1 ms |
208 KB |
Output is correct |
26 |
Correct |
4 ms |
208 KB |
Output is correct |
27 |
Correct |
5 ms |
328 KB |
Output is correct |
28 |
Correct |
3 ms |
332 KB |
Output is correct |
29 |
Correct |
4 ms |
208 KB |
Output is correct |
30 |
Correct |
4 ms |
208 KB |
Output is correct |
31 |
Correct |
4 ms |
328 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 |
208 KB |
Output is correct |
35 |
Correct |
6 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
3 ms |
208 KB |
Output is correct |
3 |
Correct |
2 ms |
336 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 |
320 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 |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
208 KB |
Output is correct |
12 |
Correct |
1 ms |
208 KB |
Output is correct |
13 |
Correct |
1 ms |
208 KB |
Output is correct |
14 |
Correct |
2 ms |
336 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 |
336 KB |
Output is correct |
19 |
Correct |
1 ms |
208 KB |
Output is correct |
20 |
Correct |
8 ms |
336 KB |
Output is correct |
21 |
Correct |
7 ms |
208 KB |
Output is correct |
22 |
Correct |
7 ms |
332 KB |
Output is correct |
23 |
Correct |
4 ms |
208 KB |
Output is correct |
24 |
Correct |
4 ms |
208 KB |
Output is correct |
25 |
Correct |
1 ms |
208 KB |
Output is correct |
26 |
Correct |
4 ms |
208 KB |
Output is correct |
27 |
Correct |
5 ms |
328 KB |
Output is correct |
28 |
Correct |
3 ms |
332 KB |
Output is correct |
29 |
Correct |
4 ms |
208 KB |
Output is correct |
30 |
Correct |
4 ms |
208 KB |
Output is correct |
31 |
Correct |
4 ms |
328 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 |
208 KB |
Output is correct |
35 |
Correct |
6 ms |
332 KB |
Output is correct |
36 |
Incorrect |
7 ms |
1064 KB |
1st lines differ - on the 1st token, expected: '5765', found: '1' |
37 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
371 ms |
1456 KB |
1st lines differ - on the 1st token, expected: '11903', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
176 ms |
564 KB |
1st lines differ - on the 1st token, expected: '7197', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
3 ms |
208 KB |
Output is correct |
3 |
Correct |
2 ms |
336 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 |
320 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 |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
208 KB |
Output is correct |
12 |
Correct |
1 ms |
208 KB |
Output is correct |
13 |
Correct |
1 ms |
208 KB |
Output is correct |
14 |
Correct |
2 ms |
336 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 |
336 KB |
Output is correct |
19 |
Correct |
1 ms |
208 KB |
Output is correct |
20 |
Correct |
8 ms |
336 KB |
Output is correct |
21 |
Correct |
7 ms |
208 KB |
Output is correct |
22 |
Correct |
7 ms |
332 KB |
Output is correct |
23 |
Correct |
4 ms |
208 KB |
Output is correct |
24 |
Correct |
4 ms |
208 KB |
Output is correct |
25 |
Correct |
1 ms |
208 KB |
Output is correct |
26 |
Correct |
4 ms |
208 KB |
Output is correct |
27 |
Correct |
5 ms |
328 KB |
Output is correct |
28 |
Correct |
3 ms |
332 KB |
Output is correct |
29 |
Correct |
4 ms |
208 KB |
Output is correct |
30 |
Correct |
4 ms |
208 KB |
Output is correct |
31 |
Correct |
4 ms |
328 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 |
208 KB |
Output is correct |
35 |
Correct |
6 ms |
332 KB |
Output is correct |
36 |
Incorrect |
7 ms |
1064 KB |
1st lines differ - on the 1st token, expected: '5765', found: '1' |
37 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
341 ms |
920 KB |
Output is correct |
2 |
Correct |
777 ms |
1448 KB |
Output is correct |
3 |
Correct |
802 ms |
1356 KB |
Output is correct |
4 |
Correct |
736 ms |
1440 KB |
Output is correct |
5 |
Correct |
780 ms |
1488 KB |
Output is correct |
6 |
Correct |
901 ms |
1352 KB |
Output is correct |
7 |
Correct |
609 ms |
1432 KB |
Output is correct |
8 |
Correct |
0 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 |
3 ms |
208 KB |
Output is correct |
13 |
Correct |
2 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
208 KB |
Output is correct |
17 |
Correct |
1 ms |
320 KB |
Output is correct |
18 |
Correct |
1 ms |
208 KB |
Output is correct |
19 |
Correct |
1 ms |
208 KB |
Output is correct |
20 |
Correct |
1 ms |
336 KB |
Output is correct |
21 |
Correct |
1 ms |
208 KB |
Output is correct |
22 |
Correct |
1 ms |
208 KB |
Output is correct |
23 |
Correct |
1 ms |
208 KB |
Output is correct |
24 |
Correct |
2 ms |
336 KB |
Output is correct |
25 |
Correct |
1 ms |
208 KB |
Output is correct |
26 |
Correct |
4 ms |
208 KB |
Output is correct |
27 |
Correct |
1 ms |
208 KB |
Output is correct |
28 |
Correct |
1 ms |
336 KB |
Output is correct |
29 |
Correct |
1 ms |
208 KB |
Output is correct |
30 |
Correct |
8 ms |
336 KB |
Output is correct |
31 |
Correct |
7 ms |
208 KB |
Output is correct |
32 |
Correct |
7 ms |
332 KB |
Output is correct |
33 |
Correct |
4 ms |
208 KB |
Output is correct |
34 |
Correct |
4 ms |
208 KB |
Output is correct |
35 |
Correct |
1 ms |
208 KB |
Output is correct |
36 |
Correct |
4 ms |
208 KB |
Output is correct |
37 |
Correct |
5 ms |
328 KB |
Output is correct |
38 |
Correct |
3 ms |
332 KB |
Output is correct |
39 |
Correct |
4 ms |
208 KB |
Output is correct |
40 |
Correct |
4 ms |
208 KB |
Output is correct |
41 |
Correct |
4 ms |
328 KB |
Output is correct |
42 |
Correct |
3 ms |
208 KB |
Output is correct |
43 |
Correct |
3 ms |
208 KB |
Output is correct |
44 |
Correct |
3 ms |
208 KB |
Output is correct |
45 |
Correct |
6 ms |
332 KB |
Output is correct |
46 |
Incorrect |
7 ms |
1064 KB |
1st lines differ - on the 1st token, expected: '5765', found: '1' |
47 |
Halted |
0 ms |
0 KB |
- |