#include <bits/stdc++.h>
#ifdef LOCAL
#include "/home/trcmai/code/tools.h"
#define debug(x...) cerr << "\e[91m"<<__func__<<":"<<__LINE__<<" [" << #x << "] = ["; _print(x); cerr << "\e[39m" << endl;
#else
#define debug(x...)
#endif
using namespace std;
#define all(a) a.begin(), a.end()
#define ll long long
#define endl '\n'
const int N = 1e6 + 6, LOG = 27, MOD = 1e9 + 7;
const ll INF = 1e18;
int n,q; ll a[N],st[4*N];
void build(int i,int l,int r){
if(l == r){st[i] = a[l]; return;}
int m = (r+l) >> 1;
build(2*i,l,m); build(2*i+1,m+1,r);
st[i] = max(st[2*i],st[2*i+1]);
}
ll get(int i,int l,int r,int ql,int qr){
if(l > qr || r < ql) return 0;
if(ql <= l && r <= qr) return st[i];
int m = (r+l) >> 1;
return max(get(2*i,l,m,ql,qr),get(2*i+1,m+1,r,ql,qr));
}
signed main() {
cin.tie(0)->sync_with_stdio(0);
auto solver=[&](){
cin>>n>>q;
for(int i = 1;i <= n;++i) cin>>a[i];
build(1,1,n);
while(q--){
int l,r,k; cin>>l>>r>>k;
bool res = true;
for(int i = l + 1;i <= r;++i){
ll mx = get(1,1,n,l,i - 1);
if(mx < a[i]) continue;
if(mx + a[i] > k){
res = false;
break;
}
}
cout<<res<<endl;
}
};
int t = 1; // cin>>t;
while (t--) solver();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
6 ms |
2532 KB |
Output is correct |
9 |
Correct |
3 ms |
2396 KB |
Output is correct |
10 |
Incorrect |
2 ms |
2396 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
6 ms |
2532 KB |
Output is correct |
9 |
Correct |
3 ms |
2396 KB |
Output is correct |
10 |
Incorrect |
2 ms |
2396 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
514 ms |
58296 KB |
Output is correct |
2 |
Correct |
520 ms |
59308 KB |
Output is correct |
3 |
Correct |
499 ms |
59092 KB |
Output is correct |
4 |
Correct |
535 ms |
59472 KB |
Output is correct |
5 |
Execution timed out |
3028 ms |
38896 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3011 ms |
5108 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
6 ms |
2532 KB |
Output is correct |
9 |
Correct |
3 ms |
2396 KB |
Output is correct |
10 |
Incorrect |
2 ms |
2396 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
6 ms |
2532 KB |
Output is correct |
9 |
Correct |
3 ms |
2396 KB |
Output is correct |
10 |
Incorrect |
2 ms |
2396 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |