# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
344099 | Nurlykhan | Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) | C++17 | 3069 ms | 8512 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 <bits/stdc++.h>
using namespace std;
const int N = (int)1e6 + 10;
const int K = 2;
int n, m;
int w[N];
bool bad[N];
int max_value[N], max_mood[N];
int main() {
scanf("%d%d", &n, &m);
for (int i = 0; i < n; i++) {
scanf("%d", &w[i]);
}
for (int i = 0; i < n; i++) {
int block_id = i / K;
max_value[block_id] = max(max_value[block_id], w[i]);
for (int j = i; j < (block_id + 1) * K; j++) {
if (w[i] > w[j]) {
max_mood[block_id] = max(max_mood[block_id], w[i] + w[j]);
}
}
}
while (m--) {
int l, r, k;
scanf("%d%d%d", &l, &r, &k);
--l, --r;
int mx = 0, mxx = 0;
for (int i = l; i <= r; ) {
if (i % K == 0 && i + K - 1 <= r) {
mx = max(mx, max_mood[i / K]);
if (mxx <= max_value[i / K]) {
mxx = max_value[i / K];
} else {
mx = max(mx, mxx + max_value[i / K]);
}
i += K;
} else {
if (mxx <= w[i]) {
mxx = w[i];
} else {
mx = max(mx, mxx + w[i]);
}
i++;
}
}
if (k >= mx) {
printf("1\n");
} else {
printf("0\n");
}
}
return 0;
}
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... |