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;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long n, m;
cin >> n >> m;
vector<int> books(n);
vector<vector<int>> days(m, vector<int>(3));
for (int i = 0; i < n; i++) {
cin >> books[i];
}
for (int i = 0; i < m; i++) {
cin >> days[i][0] >> days[i][1] >> days[i][2];
bool broken = false;
for (int k = days[i][0] - 1; k < days[i][1] - 1; k++) {
if (books[k] > books[k + 1]) {
if (books[k] + books[k + 1] <= days[i][2]) {
swap(books[k], books[k + 1]);
} else {
broken = true;
break;
}
}
}
if (broken) {
cout << 0 << "\n";
} else {
cout << 1 << "\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... |