Submission #1095352

#TimeUsernameProblemLanguageResultExecution timeMemory
1095352eysbutnoHedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++17
17 / 100
3029 ms43600 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = array<int, 2>; #define all(x) begin(x), end(x) #define sz(x) (int) (x).size() int main() { cin.tie(0) -> sync_with_stdio(0); int n, q; cin >> n >> q; vector<int> w(n); for (int &i : w) { cin >> i; } while (q--) { int l, r, k; cin >> l >> r >> k; --l, --r; set<int> seen; int worst = -1; for (int i = r; i >= l; i--) { auto it = seen.lower_bound(w[i]); if (it != begin(seen)) { it = prev(it); worst = max(worst, *it + w[i]); } seen.insert(w[i]); } cout << (worst <= k) << "\n"; } }
#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...