#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];
for(ll i=1;i<=n;++i){
cin>>ar[i];
}
while(q--){
cin>>l>>r>>w;
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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
476 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
476 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
21 ms |
564 KB |
Output is correct |
12 |
Correct |
70 ms |
604 KB |
Output is correct |
13 |
Correct |
77 ms |
604 KB |
Output is correct |
14 |
Correct |
133 ms |
728 KB |
Output is correct |
15 |
Correct |
131 ms |
604 KB |
Output is correct |
16 |
Correct |
278 ms |
936 KB |
Output is correct |
17 |
Correct |
155 ms |
600 KB |
Output is correct |
18 |
Correct |
95 ms |
660 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3036 ms |
33700 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3022 ms |
3640 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
476 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
21 ms |
564 KB |
Output is correct |
12 |
Correct |
70 ms |
604 KB |
Output is correct |
13 |
Correct |
77 ms |
604 KB |
Output is correct |
14 |
Correct |
133 ms |
728 KB |
Output is correct |
15 |
Correct |
131 ms |
604 KB |
Output is correct |
16 |
Correct |
278 ms |
936 KB |
Output is correct |
17 |
Correct |
155 ms |
600 KB |
Output is correct |
18 |
Correct |
95 ms |
660 KB |
Output is correct |
19 |
Execution timed out |
3063 ms |
7644 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
476 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
21 ms |
564 KB |
Output is correct |
12 |
Correct |
70 ms |
604 KB |
Output is correct |
13 |
Correct |
77 ms |
604 KB |
Output is correct |
14 |
Correct |
133 ms |
728 KB |
Output is correct |
15 |
Correct |
131 ms |
604 KB |
Output is correct |
16 |
Correct |
278 ms |
936 KB |
Output is correct |
17 |
Correct |
155 ms |
600 KB |
Output is correct |
18 |
Correct |
95 ms |
660 KB |
Output is correct |
19 |
Execution timed out |
3036 ms |
33700 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |