Submission #598927

#TimeUsernameProblemLanguageResultExecution timeMemory
598927JomnoiHedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++17
17 / 100
3091 ms30764 KiB
#include <bits/stdc++.h> using namespace std; const int MAX_N = 1e6 + 5; int w[MAX_N]; int main() { cin.tie(nullptr)->sync_with_stdio(false); int N, M; cin >> N >> M; for(int i = 1; i <= N; i++) { cin >> w[i]; } while(M--) { int l, r, k; cin >> l >> r >> k; multiset <int> s; for(int i = l; i <= r; i++) { s.insert(w[i]); } int ma = 0; for(int i = l; i < r; i++) { s.erase(s.lower_bound(w[i])); auto it = s.lower_bound(w[i]); if(it != s.begin()) { ma = max(ma, w[i] + *prev(it)); } } cout << (ma <= 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...