# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
155989 | ASDF123 | Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) | C++14 | 3105 ms | 48112 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>
#define fr first
#define sc
using namespace std;
const int N = (int)1e6 + 5;
const int INF = 1e9 + 7;
const int MOD = (int)1e9 + 7;
int n, l, r, k, tests;
int a[N];
void solve() {
scanf("%d%d%d", &l, &r, &k);
set <int> st;
set <int> ::iterator it;
bool ok = true;
int mn = INF;
for (int i = r; i >= l; i--) {
if (i == r) {
st.insert(a[i]);
mn = min(mn, a[i]);
continue;
}
if (mn < a[i]) {
it = st.lower_bound(a[i]);
it--;
if (*it + a[i] > k) {
ok = false;
break;
}
}
st.insert(a[i]);
mn = min(mn, a[i]);
}
if (ok) {
puts("1");
} else {
puts("0");
}
}
main() {
scanf("%d%d", &n, &tests);
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
}
while (tests--) {
solve();
}
}
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... |