이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "towers.h"
using namespace std;
typedef long long ll;
int n;
vector<int> h;
void init(int N, vector<int> H) {
n = N; h = H;
}
int max_towers(int L, int R, int D) {
int res = 1;
int mn = 1 << 30, mx = 0;
bool foundK = false;
for (int i = L; i <= R; i++) {
if (!foundK) {
if (h[i] >= mn+D) {
foundK = true;
mx = h[i];
continue;
}
mn = min(mn, h[i]);
}
else {
if (h[i] <= mx-D) {
foundK = false;
res++;
mn = h[i];
continue;
}
mx = max(mx, h[i]);
}
}
return res;
}
# | 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... |