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;
using idata = vector<int>;
idata heights;
int nbTowers;
void init(int N, idata H) {
nbTowers = N;
heights = H;
}
int max_towers(int L, int R, int D) {
int curr = L; bool middle = false;
int count = 1;
for (int local = L + 1; local <= R; local ++) {
if (middle) {
if (heights[curr] >= heights[local] + D) {
curr = local;
middle = false;
count ++;
} else if (heights[local] > heights[curr]) curr = local;
} else {
if (heights[local] >= heights[curr] + D) {
curr = local;
middle = true;
} else if (heights[local] < heights[curr]) curr = local;
}
}
return count;
}
# | 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... |