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 ans = 0, m = 2e9;
bool inter = true;
for (int i = L; i <= R; ++i) {
if (!inter) {
if (h[i] < m) m = h[i];
else if (h[i] - D >= m) inter = true, m = h[i];
} else {
if (h[i] > m) m = h[i];
else if (m - D >= h[i]) inter = false, ans++, m = 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... |