| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1357244 | Johan | Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) | C++20 | 1833 ms | 18080 KiB |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 5;
int n, m;
long long w[MAXN], bad[MAXN];
int B; // block size
long long block_max[2000]; // enough for sqrt(1e6)
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> m;
for (int i = 1; i <= n; i++) cin >> w[i];
// build bad[]
for (int i = 1; i < n; i++) {
if (w[i] > w[i+1]) bad[i] = w[i] + w[i+1];
else bad[i] = 0;
}
// sqrt block size
B = sqrt(n) + 1;
// build blocks
for (int i = 1; i < n; i++) {
int b = i / B;
block_max[b] = max(block_max[b], bad[i]);
}
while (m--) {
int l, r;
long long k;
cin >> l >> r >> k;
if (l == r) {
cout << 1 << '\n';
continue;
}
long long mx = 0;
int L = l, R = r - 1;
// left part
while (L <= R && L % B != 0) {
mx = max(mx, bad[L]);
L++;
}
// full blocks
while (L + B - 1 <= R) {
mx = max(mx, block_max[L / B]);
L += B;
}
// right part
while (L <= R) {
mx = max(mx, bad[L]);
L++;
}
cout << (mx <= k) << '\n';
}
return 0;
}| # | 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... | ||||
