제출 #993016

#제출 시각아이디문제언어결과실행 시간메모리
993016serkanrashidHedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++14
30 / 100
3097 ms27408 KiB
#include <bits/stdc++.h> #define endl "\n" using namespace std; const int maxn = 1e6+5; int n,m; int w[maxn],pref[maxn]; bool check(int l, int r, int k) { int maxch = 0; int razmqna = 0; for(int i = l; i <= r; i++) { if(maxch>w[i]) razmqna = max(razmqna,maxch+w[i]); maxch = max(maxch,w[i]); } return k >= razmqna; } void read() { cin >> n >> m; int minch = 1e9; for(int i = 1; i <= n; i++) { cin >> w[i]; minch = min(minch,w[i]); } for(int i = 2; i <= n; i++) { pref[i] = pref[i-1]; if(w[i-1]<=w[i]) pref[i]++; } int l,r,k; for(int i = 1; i <= m; i++) { cin >> l >> r >> k; if(minch>k) { if(pref[r]-pref[l] == r-l) cout << 1 << endl; else cout << 0 << endl; } else { if(check(l,r,k)) cout << 1 << endl; else cout << 0 << endl; } } } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); read(); 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...