#include "towers.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> a;
int n;
void init(int N, vector<int> H) {
a = H, n = N;
}
int max_towers(int L, int R, int D) {
int dp[n];
fill(dp, dp+n, 1);
for (int i = L; i <= R; ++i) {
int j = i, mx = 0;
for (; j < n; ++j) {
mx = max(a[j], mx);
if (a[j] <= mx - D && a[i] <= mx - D) break;
}
if (j <= R) dp[j] = max(dp[j], dp[i] + 1);
if (i != L) dp[i] = max(dp[i], dp[i-1]);
}
return dp[R];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |