#include "towers.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int N;
vector<int> H;
void init(int _N, vector<int> _H) {
N = _N;
H = _H;
}
int max_towers(int L, int R, int D) { R++;
auto dc = [&](auto dc, int l, int r, int lim) -> int {
if (l >= r) return 0;
int x = l, mn = H[l];
for (int i = l; i < r; i++) {
if (H[i] > H[x]) x = i;
mn = min(mn, H[i]);
}
return max({mn <= lim ? 1 : 0, dc(dc, l, x, min(lim, H[x] - D)) + dc(dc, x + 1, r, min(lim, H[x] - D)), dc(dc, l, x, lim), dc(dc, x + 1, r, lim)});
};
return dc(dc, L, R, numeric_limits<int>::max());
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
4061 ms |
2772 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
338 ms |
296 KB |
Output is correct |
3 |
Correct |
375 ms |
208 KB |
Output is correct |
4 |
Correct |
2141 ms |
300 KB |
Output is correct |
5 |
Correct |
479 ms |
308 KB |
Output is correct |
6 |
Correct |
22 ms |
208 KB |
Output is correct |
7 |
Correct |
105 ms |
296 KB |
Output is correct |
8 |
Execution timed out |
4081 ms |
208 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
338 ms |
296 KB |
Output is correct |
3 |
Correct |
375 ms |
208 KB |
Output is correct |
4 |
Correct |
2141 ms |
300 KB |
Output is correct |
5 |
Correct |
479 ms |
308 KB |
Output is correct |
6 |
Correct |
22 ms |
208 KB |
Output is correct |
7 |
Correct |
105 ms |
296 KB |
Output is correct |
8 |
Execution timed out |
4081 ms |
208 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
4088 ms |
1360 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
4049 ms |
464 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
338 ms |
296 KB |
Output is correct |
3 |
Correct |
375 ms |
208 KB |
Output is correct |
4 |
Correct |
2141 ms |
300 KB |
Output is correct |
5 |
Correct |
479 ms |
308 KB |
Output is correct |
6 |
Correct |
22 ms |
208 KB |
Output is correct |
7 |
Correct |
105 ms |
296 KB |
Output is correct |
8 |
Execution timed out |
4081 ms |
208 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
4061 ms |
2772 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |