#include <bits/stdc++.h>
#include "towers.h"
#define ll long long
#define ar array
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
using namespace std;
template<typename T> bool ckmin(T &a, const T &b ) { return a > b ? a = b, 1 : 0; }
template<typename T> bool ckmax(T &a, const T &b ) { return a < b ? a = b, 1 : 0; }
int N; vector<int> h;
void init(int _N, std::vector<int> H) {
N = _N;
h = H;
}
int max_towers(int L, int R, int D) {
auto solve = [&](auto&& s, int l, int r, int lim) -> int {
if (l > r) return 0;
if (l == r) return h[l] <= lim;
int p = l;
for (int i = l+1; i < r; i++) if (h[i] > h[p]) p = i;
return max(int(h[p] <= lim), s(s, l, p-1, min(lim, h[p] - D)) + s(s, p+1, r, min(lim, h[p] - D)));
};
return solve(solve, L, R, 1e9);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4035 ms |
1636 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
344 KB |
1st lines differ - on the 1st token, expected: '292', found: '277' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
344 KB |
1st lines differ - on the 1st token, expected: '292', found: '277' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4049 ms |
1368 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4078 ms |
600 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
344 KB |
1st lines differ - on the 1st token, expected: '292', found: '277' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4035 ms |
1636 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |