Submission #679978

#TimeUsernameProblemLanguageResultExecution timeMemory
679978Hacv16Hedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++17
17 / 100
424 ms31860 KiB
#include <bits/stdc++.h> using namespace std; #define fr first #define sc second typedef long long ll; const int MAX = 1e6 + 10; const int INF = 0x3f3f3f3f; int n, m, a[MAX], bad[MAX]; int query(int l, int r, int k){ int mx = a[l], t = 0; for(int i = l + 1; i <= r; i++){ if(mx > a[i]) t = max(t, mx + a[i]); mx = max(mx, a[i]); } return (t <= k); } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> m; for(int i = 1; i <= n; i++) cin >> a[i]; if(n <= 5000 && m <= 5000){ while(m--){ int l, r, k; cin >> l >> r >> k; cout << query(l, r, k) << '\n'; } }else{ for(int i = 1; i <= n; i++){ if(a[i] < a[i - 1]) bad[i] = i; else bad[i] = bad[i - 1]; } while(m--){ int l, r, k; cin >> l >> r >> k; cout << (bad[r] >= l) << '\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...