#include<bits/stdc++.h>
#define pb push_back
using namespace std;
vector < long long > a;
bool Solve(long long l , long long r , long long k)
{
if(k == 0) return 0;
long long Max = 0;
for(long long c = l - 1 ; c < r ; c++)
{
if(a[c] > Max)
{
Max = a[c];
}
else
{
if(Max + a[c] > k)
{
return 0;
}
}
}
return 1;
}
int main()
{
long long n , q , i , x , l , r , k;
cin >> n >> q;
for(i = 0 ; i < n ; i++)
{
cin >> x;
a.pb(x);
}
for(i = 0 ; i < q ; i++)
{
cin >> l >> r >> k;
cout << Solve(l , r , k) << endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3007 ms |
12032 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
848 ms |
2552 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |