This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 6;
int n,q; long long a[N];
signed main() {
cin.tie(0)->sync_with_stdio(0);
cin>>n>>q;
for(int i = 1;i <= n;++i) cin>>a[i];
while(q--){
int l,r,k; cin>>l>>r>>k;
long long temp = 0,temp2 = a[l];
for (int i = l + 1; i <= r; i++){
if (a[i] >= temp2) temp2 = a[i];
else temp = max(temp, temp2 + a[i]);
}
cout<<(temp <= k ? 1 : 0)<<"\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |