#include "towers.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define pii pair<int, int>
const int MAX = 2e3 + 10;
int n;
int maxx;
int arr[MAX];
int dp[MAX];
void init(int N, std::vector<int> H) {
n = N;
maxx = 1;
for (int i = 1; i <= n; i++) {
if (H[i - 1] > H[maxx - 1]) maxx = i;
arr[i] = H[i - 1];
}
}
int max_towers(int lt, int rt, int d) {
lt++, rt++;
int sol = 0;
for (int i = lt; i <= rt; i++) {
dp[i] = 1;
int maxx = 0;
for (int j = i - 1; j >= lt; j--) {
if (maxx - d >= arr[j] && maxx - d >= arr[i]) {
dp[i] = max(dp[i], dp[j] + 1);
}
maxx = max(maxx, arr[j]);
}
sol = max(sol, dp[i]);
}
return sol;
}
# | 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... |