Submission #825934

#TimeUsernameProblemLanguageResultExecution timeMemory
825934borisAngelovHedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++17
0 / 100
3064 ms14484 KiB
#include <bits/stdc++.h> using namespace std; const int maxn = 1000005; int n, q; int a[maxn]; void fastIO() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } int main() { fastIO(); cin >> n >> q; for (int i = 1; i <= n; ++i) { cin >> a[i]; } for (int i = 1; i <= q; ++i) { int l, r, k; cin >> l >> r >> k; int curr = a[r]; int max_sum = 0; for (int j = r - 1; j >= l; --j) { if (curr < a[j]) { max_sum = max(max_sum, curr + a[j]); curr = a[j]; } } if (max_sum <= k) { cout << 1 << "\n"; } else { cout << 0 << "\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...