Submission #883291

#TimeUsernameProblemLanguageResultExecution timeMemory
883291AI_2512Hedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++17
0 / 100
3049 ms94052 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...