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 <bits/stdc++.h>
using namespace std;
#define ll long long
constexpr int MAXN = 1e5;
constexpr int PW = 131072;
vector<int> H;
int k;
void init(int N, vector<int> H) {
:: H = H;
k = 0;
for (int i = 0; i < N - 1; i ++) {
if (H[i] < H[i + 1]) k = i + 1;
}
}
int max_towers(int L, int R, int D) {
if (L >= k || R <= k) return 0;
int dx = k - 1;
for (int p = PW; p >= 1; p /= 2) {
if (p + dx <= R && H[p + dx] > H[k] - D) dx += p;
}
dx ++;
int sx = k + 1;
for (int p = PW; p >= 1; p /= 2) {
if (sx - p >= L && H[sx - p] > H[k] - D) sx -= p;
}
sx --;
if (sx >= L && dx <= R) return 2;
return 0;
}
# | 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... |