# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
735893 | math_rabbit_1028 | Radio Towers (IOI22_towers) | C++17 | 15 ms | 4000 KiB |
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> arr;
vector<int> upidx, downidx;
vector<int> dvalues;
void init(int N, vector<int> H) {
n = N;
for (int i = 0; i < N; i++) arr.push_back(H[i]);
if (arr[0] < arr[1]) downidx.push_back(0);
for (int i = 1; i < N - 1; i++) {
if (arr[i] > arr[i - 1] && arr[i] > arr[i + 1]) upidx.push_back(i);
if (arr[i] < arr[i - 1] && arr[i] < arr[i + 1]) downidx.push_back(i);
}
if (arr[N - 1] < arr[N - 2]) upidx.push_back(N - 1);
assert(downidx.size() == upidx.size() + 1);
for (int i = 0; i < upidx.size(); i++) {
dvalues.push_back(arr[upidx[i]] - max(arr[downidx[i]], arr[downidx[i + 1]]));
}
sort(dvalues.begin(), dvalues.end());
}
int max_towers(int L, int R, int D) {
int ans = dvalues.end() - lower_bound(dvalues.begin(), dvalues.end(), D) + 1;
return ans;
}
Compilation message (stderr)
# | 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... |