This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <vector>
int n;
std::vector<int> h;
std::vector<int> minima_sums;
void init(int N, std::vector<int> H) {
n = N;
h = H;
minima_sums.reserve(N + 1);
minima_sums.push_back(0);
for (int i = 0; i < N; i++) {
bool left_ok = i == 0 || H[i - 1] > H[i];
bool right_ok = i + 1 == N || H[i + 1] > H[i];
minima_sums.push_back(minima_sums.back() + (left_ok && right_ok));
}
}
int max_towers(int L, int R, int D) {
if (L == R) return 1;
R += 1;
int total = minima_sums[R - 1] - minima_sums[L + 1];
if (h[L + 1] > h[L]) {
total += 1;
}
if (h[R - 2] > h[R - 1]) {
total += 1;
}
return total;
}
# | 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... |