#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define pb push_back
const int N=3e5+5;
vector<bool>ans;
int arr[N];
int st[4*N];
void build(int node, int L, int R){
if(L==R){
st[node]=arr[L];
return;
}
int mid=(L+R)/2;
build(node*2,L,mid);
build(node*2+1,mid+1,R);
st[node]=max(st[node*2+1],st[node*2]);
}
int find(int node, int L, int R, int l, int r){
if(l<=L and R<=r)return st[node];
if(l>R or r<L)return 1e9;
int mid=(L+R)/2;
return max(find(node*2,L,mid,l,r),find(node*2+1,mid+1,R,l,r));
}
signed main(){
int n,q;
cin>>n>>q;
for(int i=1;i<=n;i++){
cin>>arr[i];
}
build(1,1,n);
while(q--){
int l,r,k;
cin>>l>>r>>k;
bool u=1;
for(int i=l+1;i<=r;i++){
int x=find(1,1,n,l,i-1);
if(x< arr[i])continue;
if(x+arr[i]>k)u=0;
}
ans.pb(u);
}
for(auto a:ans)cout<<a<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
84 ms |
10072 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3020 ms |
5208 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |