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 MAX_N = 1e6 + 5;
int w[MAX_N];
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int N, M;
cin >> N >> M;
for(int i = 1; i <= N; i++) {
cin >> w[i];
}
while(M--) {
int l, r, k;
cin >> l >> r >> k;
multiset <int> s;
for(int i = l; i <= r; i++) {
s.insert(w[i]);
}
int ma = 0;
for(int i = l; i < r; i++) {
s.erase(s.lower_bound(w[i]));
auto it = s.lower_bound(w[i]);
if(it != s.begin()) {
ma = max(ma, w[i] + *prev(it));
}
}
cout << (ma <= k) << '\n';
}
return 0;
}
# | 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... |