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>
#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... |