#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 + D <= lim ? 1 : 0, (l + 1 == x ? 1 : dc(dc, l, x - 1, H[x] - D)) + (r - 2 == x ? 1 : dc(dc, x + 1, r, H[x] - D)));
};
return dc(dc, L, R, numeric_limits<int>::max());
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4034 ms |
1700 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
1st lines differ - on the 1st token, expected: '13', found: '11' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
1st lines differ - on the 1st token, expected: '13', found: '11' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4030 ms |
1360 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4062 ms |
544 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
1st lines differ - on the 1st token, expected: '13', found: '11' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4034 ms |
1700 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |