# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
988973 | MercubytheFirst | Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) | C++17 | 3064 ms | 22168 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 ll = long long;
#define pb push_back
using namespace std;
#define CDIV(a, b) ((((a) - (1)) / (b)) + 1)
void solve() {
int n, Q;
cin >> n >> Q;
vector<int> v(n + 1);
for(int i = 1; i <= n; ++i) {
cin >> v[i];
}
while(Q--) {
int l, r, k;
cin >> l >> r >> k;
set<int> s;
int mx = -1;
for(int i = l; i <= r; ++i) {
if(!s.empty() and *s.rbegin() > v[i]) {
mx = max(mx, v[i] + *s.rbegin());
}
s.insert(v[i]);
}
if(mx > k) {
cout << 0 << endl;
}
else {
cout << 1 << endl;
}
}
}
signed main() {
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// signed t = 0; cin >> t; while(t --> 0)
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... |