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;
const int MAXN = 3e5 + 64;
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 ans = 0, cur = INT_MAX, flag = true;
for (int i = L; i <= R; ++i)
if (!flag) {
if (h[i] < cur)
cur = h[i];
else if (h[i] - D >= cur)
flag = true, cur = h[i];
} else {
if (h[i] > cur)
cur = h[i];
else if (cur - D >= h[i]) {
flag = false, ++ans, cur = h[i];
}
}
return ans;
}
# | 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... |