| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1366812 | mannshah1211 | Radio Towers (IOI22_towers) | C++20 | 138 ms | 1560 KiB |
#include "towers.h"
#include <bits/stdc++.h>
#include <vector>
using namespace std;
vector<int> a;
int id;
void init(int n, vector<int> h) {
a = h;
for (int i = 0; i < n - 1; i++) {
if (h[i] > h[i + 1]) {
id = i;
break;
}
}
}
int max_towers(int l, int r, int d) {
int n = a.size();
int ans = 1;
if (r < id || l > id) {
return 1;
}
{
int low = 0, high = id - 1, idx = -1;
while (low <= high) {
int mid = (low + high) >> 1;
if (a[id] - a[mid] >= d) {
idx = mid;
low = mid + 1;
} else {
high = mid - 1;
}
}
// <= idx
ans += max(idx - l, 0);
}
{
int low = id + 1, high = n - 1, idx = -1;
while (low <= high) {
int mid = (low + high) >> 1;
if (a[mid] - a[id] >= d) {
idx = mid;
high = mid - 1;
} else {
low = mid + 1;
}
}
ans += max(r - idx, 0);
}
return ans;
}
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
