이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |