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;
void solve() {
int n, m;
cin >> n >> m;
vector<int> w(n);
for (int i = 0; i < n; ++i) {
cin >> w[i];
}
for (int i = 0; i < m; ++i) {
int l, r, k;
cin >> l >> r >> k;
--l, --r;
bool able = true;
for (int j = l + 1, mx = w[l]; j <= r; ++j) {
if (mx > w[j] && mx + w[j] > k) {
able = false;
break;
}
mx = max(mx, w[j]);
}
cout << able << '\n';
}
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int T = 1;
// cin >> T;
while (T--) {
solve();
}
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... |