#include <bits/stdc++.h>
#include <math.h>
typedef long long ll;
using namespace std;
ll i, j, t, a, n, m, b, c, d, f, g;
int x[1000100], y[1000100];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cin>>n>>m;
for (a=1; a<=n; a++) cin>>x[a];
for (a=1; a<=m; a++)
{
int l, r, k;
cin>>l>>r>>k;
int ans=1;
int mx = -1e9;
for(int i = l;i <= r;i++){
if(mx > x[i] and mx + x[i] > k) ans = 0;
mx = max(mx,x[i]);
}
cout<<ans<<'\n';
// for (b=l; b<=r; b++) y[b-l+1]=x[b];
// for (b=(r-l)+1; b>=2; b=b-2)
// {
// int mmax1=y[b-1], mmax2=y[b];
// int p1=b-1, p2=b;
//// int r=0;
// for (c=b; c>=1; c--)
// {
// if (y[c]>mmax1)
// {
//// r=1;
// mmax2=mmax1;
// mmax1=y[c];
// p2=p1;
// p1=c;
// }
// }
//// for (c=1; c<=n; c++) cout<<y[c]<<" ";
//// cout<<endl;
// if (p1==b-1 and p2==b and y[b]>=y[b-1])
// {
// b++;
// continue;
// }
// if (y[p1]+y[p2]>k)
// {
// ans=0;
// break;
// }
// swap(y[b], y[p1]);
// swap(y[b-1], y[p2]);
//// for (c=1; c<=n; c++) cout<<y[c]<<" ";
//// cout<<endl;
// }
// cout<<ans<<endl;
}
}
/*
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
0 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
0 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
3 ms |
332 KB |
Output is correct |
12 |
Correct |
6 ms |
332 KB |
Output is correct |
13 |
Correct |
6 ms |
356 KB |
Output is correct |
14 |
Correct |
10 ms |
348 KB |
Output is correct |
15 |
Correct |
11 ms |
352 KB |
Output is correct |
16 |
Correct |
17 ms |
352 KB |
Output is correct |
17 |
Correct |
16 ms |
332 KB |
Output is correct |
18 |
Correct |
17 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3062 ms |
4300 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2091 ms |
908 KB |
Output is correct |
2 |
Execution timed out |
3058 ms |
836 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
0 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
3 ms |
332 KB |
Output is correct |
12 |
Correct |
6 ms |
332 KB |
Output is correct |
13 |
Correct |
6 ms |
356 KB |
Output is correct |
14 |
Correct |
10 ms |
348 KB |
Output is correct |
15 |
Correct |
11 ms |
352 KB |
Output is correct |
16 |
Correct |
17 ms |
352 KB |
Output is correct |
17 |
Correct |
16 ms |
332 KB |
Output is correct |
18 |
Correct |
17 ms |
332 KB |
Output is correct |
19 |
Execution timed out |
3096 ms |
1236 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
0 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
3 ms |
332 KB |
Output is correct |
12 |
Correct |
6 ms |
332 KB |
Output is correct |
13 |
Correct |
6 ms |
356 KB |
Output is correct |
14 |
Correct |
10 ms |
348 KB |
Output is correct |
15 |
Correct |
11 ms |
352 KB |
Output is correct |
16 |
Correct |
17 ms |
352 KB |
Output is correct |
17 |
Correct |
16 ms |
332 KB |
Output is correct |
18 |
Correct |
17 ms |
332 KB |
Output is correct |
19 |
Execution timed out |
3062 ms |
4300 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |