#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define getar(ar,n) for(ll i=0;i<n;++i) cin>>ar[i]
#define show(n) cout<<n<<'\n'
#define all(v) v.begin(), v.end()
#define br cout<<"\n"
#define pb push_back
#define nl '\n'
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define ret return
#define ll long long
#define ld long double
#define sza(x) ((int)x.size())
const int mxN = 1e5 + 5;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const ld EPS = 1e-9;
void solve() {
ll l,r,w,n,q;cin>>n>>q;
ll ar[n+1],p[n+1],mn=INF;p[0]=0;
for(ll i=1;i<=n;++i){
cin>>ar[i];
p[i]=p[i-1]+(ar[i]<ar[i-1]);
mn=min(mn,ar[i]);
}
while(q--){
cin>>l>>r>>w;
if(w<mn){
cout<<(p[r]-p[l]==0||(r-l)==0)<<nl;
continue;
}
priority_queue<ll,vector<ll>,less<ll>> q;
ll tot=0;
for(ll i=l;i<=r;++i){
q.push(ar[i]);
ll tp=q.top();
if(tp>ar[i]) tot=max(tot,ar[i]+tp);
}
if(tot<=w) show(1);
else show(0);
}
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
20 ms |
344 KB |
Output is correct |
12 |
Correct |
72 ms |
600 KB |
Output is correct |
13 |
Correct |
81 ms |
720 KB |
Output is correct |
14 |
Correct |
130 ms |
636 KB |
Output is correct |
15 |
Correct |
133 ms |
604 KB |
Output is correct |
16 |
Correct |
282 ms |
720 KB |
Output is correct |
17 |
Correct |
155 ms |
604 KB |
Output is correct |
18 |
Correct |
95 ms |
692 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
328 ms |
49492 KB |
Output is correct |
2 |
Correct |
358 ms |
50152 KB |
Output is correct |
3 |
Correct |
325 ms |
49956 KB |
Output is correct |
4 |
Correct |
335 ms |
50260 KB |
Output is correct |
5 |
Correct |
374 ms |
50192 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3046 ms |
4392 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
20 ms |
344 KB |
Output is correct |
12 |
Correct |
72 ms |
600 KB |
Output is correct |
13 |
Correct |
81 ms |
720 KB |
Output is correct |
14 |
Correct |
130 ms |
636 KB |
Output is correct |
15 |
Correct |
133 ms |
604 KB |
Output is correct |
16 |
Correct |
282 ms |
720 KB |
Output is correct |
17 |
Correct |
155 ms |
604 KB |
Output is correct |
18 |
Correct |
95 ms |
692 KB |
Output is correct |
19 |
Execution timed out |
3018 ms |
9248 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
20 ms |
344 KB |
Output is correct |
12 |
Correct |
72 ms |
600 KB |
Output is correct |
13 |
Correct |
81 ms |
720 KB |
Output is correct |
14 |
Correct |
130 ms |
636 KB |
Output is correct |
15 |
Correct |
133 ms |
604 KB |
Output is correct |
16 |
Correct |
282 ms |
720 KB |
Output is correct |
17 |
Correct |
155 ms |
604 KB |
Output is correct |
18 |
Correct |
95 ms |
692 KB |
Output is correct |
19 |
Correct |
328 ms |
49492 KB |
Output is correct |
20 |
Correct |
358 ms |
50152 KB |
Output is correct |
21 |
Correct |
325 ms |
49956 KB |
Output is correct |
22 |
Correct |
335 ms |
50260 KB |
Output is correct |
23 |
Correct |
374 ms |
50192 KB |
Output is correct |
24 |
Execution timed out |
3046 ms |
4392 KB |
Time limit exceeded |
25 |
Halted |
0 ms |
0 KB |
- |