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 "towers.h"
#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> h;
void init(int N_, vector<int> H_) {
n = N_, h = H_;
}
int max_towers(int l, int r, int d) {
int lst = l - 1;
int good_towers = 0;
for (int i = l + 1; i < r; ++i) {
if (h[i] < h[i - 1] || h[i] < h[i + 1]) {
continue;
}
int mn = h[lst + 1];
for (int j = lst + 1; j < i; ++j) {
mn = min(mn, h[j]);
}
if (h[i] - mn >= d) {
lst = i;
good_towers++;
}
}
return good_towers + 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... |