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>
#include <iostream>
int n;
std::vector<int> h;
void init(int N, std::vector<int> H) {
n = N;
h = H;
}
int max_towers(int L, int R, int D) {
if (L == R) return 1;
R += 1;
std::vector<int> included { h[L] };
int greatest = h[L];
for (int i = L + 1; i < R; i++) {
if (h[i] > greatest) {
greatest = h[i];
} else if (greatest - included.back() < D) {
if (h[i] < included.back()) {
included.pop_back();
included.push_back(h[i]);
greatest = h[i];
}
} else {
included.push_back(h[i]);
greatest = h[i];
}
}
return included.size();
}
# | 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... |