#include <iostream>
using namespace std;
const int maxN = 1000005;
int arr[maxN];
int solve(int start, int finish, int mood)
{
int maxNum = arr[start - 1];
for (int i = start; i < finish; i++)
{
if (maxNum > arr[i])
{
if (arr[i] + maxNum > mood)
{
return false;
}
}
else
{
maxNum = arr[i];
}
}
return true;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, m;
cin >> n >> m;
for (int i = 0; i < n; i++)
{
cin >> arr[i];
}
for (int i = 0; i < m; i++)
{
int start, finish, mood;
cin >> start >> finish >> mood;
cout << solve(start, finish, mood)<<endl;
}
}
/*
5 2
3 5 1 8 2
1 3 6
2 5 3
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 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 |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 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 |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
6 ms |
332 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
6 ms |
396 KB |
Output is correct |
14 |
Correct |
12 ms |
336 KB |
Output is correct |
15 |
Correct |
12 ms |
460 KB |
Output is correct |
16 |
Correct |
17 ms |
440 KB |
Output is correct |
17 |
Correct |
24 ms |
424 KB |
Output is correct |
18 |
Correct |
16 ms |
412 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1730 ms |
6176 KB |
Output is correct |
2 |
Correct |
1663 ms |
6152 KB |
Output is correct |
3 |
Correct |
1635 ms |
6216 KB |
Output is correct |
4 |
Correct |
1639 ms |
6152 KB |
Output is correct |
5 |
Execution timed out |
3066 ms |
4308 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
648 ms |
1172 KB |
Output is correct |
2 |
Correct |
1943 ms |
1036 KB |
Output is correct |
3 |
Execution timed out |
3092 ms |
1012 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 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 |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
6 ms |
332 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
6 ms |
396 KB |
Output is correct |
14 |
Correct |
12 ms |
336 KB |
Output is correct |
15 |
Correct |
12 ms |
460 KB |
Output is correct |
16 |
Correct |
17 ms |
440 KB |
Output is correct |
17 |
Correct |
24 ms |
424 KB |
Output is correct |
18 |
Correct |
16 ms |
412 KB |
Output is correct |
19 |
Correct |
2424 ms |
1632 KB |
Output is correct |
20 |
Correct |
2548 ms |
1432 KB |
Output is correct |
21 |
Execution timed out |
3090 ms |
1240 KB |
Time limit exceeded |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 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 |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
6 ms |
332 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
6 ms |
396 KB |
Output is correct |
14 |
Correct |
12 ms |
336 KB |
Output is correct |
15 |
Correct |
12 ms |
460 KB |
Output is correct |
16 |
Correct |
17 ms |
440 KB |
Output is correct |
17 |
Correct |
24 ms |
424 KB |
Output is correct |
18 |
Correct |
16 ms |
412 KB |
Output is correct |
19 |
Correct |
1730 ms |
6176 KB |
Output is correct |
20 |
Correct |
1663 ms |
6152 KB |
Output is correct |
21 |
Correct |
1635 ms |
6216 KB |
Output is correct |
22 |
Correct |
1639 ms |
6152 KB |
Output is correct |
23 |
Execution timed out |
3066 ms |
4308 KB |
Time limit exceeded |