#include "towers.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 2002;
int h[N];
bool f[N];
int n;
void init(int N, std::vector<int> H) {
n = N;
for (int i = 0; i < n; i++)
h[i] = H[i];
}
int solve (int l, int r, int d) {
if (l > r)
return 0;
if (l == r)
return f[l];
int mx = -1, in = -1;
for (int i = l; i <= r; i++) {
if (h[i] > mx) {
mx = h[i];
in = i;
}
}
int fin = (int)f[in];
if (f[in]) {
for (int i = l; i <= r; i++) {
if (h[i] > mx - d)
f[i] = false;
}
}
return max (fin, solve (l, in - 1, d) + solve(in + 1, r, d));
}
int max_towers(int L, int R, int D) {
for (int i = 0; i < N; i++)
f[i] = true;
return 10;
return max (1, solve (L, R, D));
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
5 ms |
1368 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
1st lines differ - on the 1st token, expected: '13', found: '10' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
1st lines differ - on the 1st token, expected: '13', found: '10' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
14 ms |
2136 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
856 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
1st lines differ - on the 1st token, expected: '13', found: '10' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
5 ms |
1368 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |