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;
bool canSort(vector<int>& a, int l, int r, int k) {
int maxVal = 0;
for (int i = l; i <= r; ++i) {
if (maxVal > a[i] && maxVal + a[i] > k) {
return false;
}
maxVal = max(maxVal, a[i]);
}
return true;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n, m;
cin >> n >> m;
vector<int> a(n);
for (auto& i : a) {
cin >> i;
}
int minEl = *min_element(a.begin(), a.end());
bool isGood = is_sorted(a.begin(), a.end());
while (m--) {
int l, r, k;
cin >> l >> r >> k;
if (k < minEl) {
cout << isGood << '\n';
}
--l, --r;
cout << canSort(a, l, r, 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... |