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<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, last = h[l];
for (int i = l + 1; i <= r; ++i) {
if (res & 1) {
if (h[i] >= last + d) {
++res;
last = h[i];
} else {
last = min(last, h[i]);
}
} else {
if (h[i] + d <= last) {
++res;
last = h[i];
} else {
last = max(last, h[i]);
}
}
}
return (res + 1) / 2;
}
# | 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... |