제출 #501899

#제출 시각아이디문제언어결과실행 시간메모리
501899nightyHedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++14
17 / 100
3083 ms6140 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'; continue; } --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...