#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;
for (; j <= R; ++j) {
if (a[j] >= a[i] + D) break;
}
int jj = j;
for (; jj <= R; ++jj) {
if (a[jj] <= a[j] - D) break;
}
if (jj <= R) dp[jj] = max(dp[jj], dp[i] + 1);
if (i) 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... |