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<pair<int, int>> H;
int k;
void init(int N, vector<int> H) {
::N = N;
for (int i = 0; i < N; i++) {
::H[i].first = H[i];
::H[i].second = i;
}
if (N == 2) {
if (H[0] > H[1]) k = 0;
else k = 1;
}
for (int i = 1; i < N - 1; i++) {
if (H[i - 1] < H[i] && H[i] > H[i - 1]) k = i;
}
}
int max_towers(int L, int R, int D) {
if (k >= L && k <= R) {
int lf = H[L].first;
int rg = H[R].first;
int ma = max(lf, rg);
if (H[k].first - ma >= D) return 2;
return 1;
} else {
return 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... |