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;
const int LOG = 18;
int n;
int k;
vector<int> h;
vector<int> pref;
void init(int N_, vector<int> H_) {
n = N_, h = H_;
pref.resize(n - 1);
for (int i = 1; i < n - 1; ++i) {
pref[i] = (h[i - 1] < h[i]) && (h[i] > h[i + 1]);
}
for (int i = 1; i < n - 1; ++i) {
pref[i] += pref[i - 1];
}
}
int max_towers(int l, int r, int d) {
assert(d == 1);
if (l == r) {
return 1;
}
int ans = pref[r - 1] - pref[l] + 1;
return ans;
}
# | 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... |