// Fuck It We BALL
#include "towers.h"
#include <bits/stdc++.h>
using namespace std;
#define chmax(a, b) a = max(a, b)
#define pb push_back
#define ALL(a) a.begin(), a.end()
#define LC (v<<1)
#define RC (LC|1)
#define mid ((l+r) / 2)
const int mxn = 1e5 + 4;
int n;
int h[mxn];
void init(int N, std::vector<int> H) {
n = N;
for (int i=0; i<n; i++) h[i+1] = H[i];
}
int max_towers(int L, int R, int D) {
L++; R++;
int ans = 0;
for (int i = L; i <= R; i++) {
int add = 0;
int MAX = 0;
for (int j = i+1; j <= R; j++) {
if (h[i] > h[j]) break;
if (h[j] <= MAX-D) add = 1;
chmax(MAX, h[j]);
}
for (int j = i-1; j >= L; j--) {
if (h[i] > h[j]) break;
if (h[j] <= MAX-D) add = 1;
chmax(MAX, h[j]);
}
ans += add;
}
return max(ans, 1);
}
# | 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... |