This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define fs first
#define sc second
#define pb push_back
void solve() {
int n,q;
cin>>n>>q;
int a[n];
for(int i=0;i<n;i++)cin>>a[i];
while(q--){
int l,r,k;
cin>>l>>r>>k;
l--;r--;
int mx=0;
for(int i=l;i<=r;i++){
for(int j=i+1;j<=r;j++){
if(a[i]>a[j])mx=max(mx,a[i]+a[j]);
}
}
if(mx<=k)cout<<"1\n";
else cout<<"0\n";
}
}
int main() {
#ifdef FPO
freopen("in","r",stdin);
freopen("out","w",stdout);
#endif
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
solve();
}
# | 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... |