Submission #501898

#TimeUsernameProblemLanguageResultExecution timeMemory
501898nightyHedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++14
0 / 100
3056 ms8232 KiB
#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 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...