#include <iostream>
using namespace std;
const int maxN = 100005;
int arr[maxN];
int solve(int start, int finish, int mood)
{
int len = finish - start + 1;
int newArr[maxN];
for (int i = 0; i < len; i++)
{
newArr[i] = arr[start - 1 + i];
}
for (int i = 0; i < len; i++)
{
for (int j = 0; j < len - i - 1; j++)
{
if (newArr[j] > newArr[j + 1])
{
if (newArr[j] + newArr[j + 1] > mood)
{
return false;
}
swap(newArr[j], newArr[j + 1]);
}
}
}
return true;
}
int main()
{
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 |
584 KB |
Output is correct |
2 |
Correct |
1 ms |
688 KB |
Output is correct |
3 |
Correct |
3 ms |
592 KB |
Output is correct |
4 |
Correct |
2 ms |
592 KB |
Output is correct |
5 |
Correct |
1 ms |
592 KB |
Output is correct |
6 |
Correct |
3 ms |
592 KB |
Output is correct |
7 |
Correct |
3 ms |
592 KB |
Output is correct |
8 |
Correct |
19 ms |
592 KB |
Output is correct |
9 |
Correct |
4 ms |
592 KB |
Output is correct |
10 |
Correct |
4 ms |
592 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
584 KB |
Output is correct |
2 |
Correct |
1 ms |
688 KB |
Output is correct |
3 |
Correct |
3 ms |
592 KB |
Output is correct |
4 |
Correct |
2 ms |
592 KB |
Output is correct |
5 |
Correct |
1 ms |
592 KB |
Output is correct |
6 |
Correct |
3 ms |
592 KB |
Output is correct |
7 |
Correct |
3 ms |
592 KB |
Output is correct |
8 |
Correct |
19 ms |
592 KB |
Output is correct |
9 |
Correct |
4 ms |
592 KB |
Output is correct |
10 |
Correct |
4 ms |
592 KB |
Output is correct |
11 |
Correct |
16 ms |
764 KB |
Output is correct |
12 |
Correct |
24 ms |
916 KB |
Output is correct |
13 |
Correct |
28 ms |
820 KB |
Output is correct |
14 |
Correct |
68 ms |
848 KB |
Output is correct |
15 |
Correct |
24 ms |
856 KB |
Output is correct |
16 |
Execution timed out |
3067 ms |
696 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
38 ms |
2252 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3033 ms |
1660 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
584 KB |
Output is correct |
2 |
Correct |
1 ms |
688 KB |
Output is correct |
3 |
Correct |
3 ms |
592 KB |
Output is correct |
4 |
Correct |
2 ms |
592 KB |
Output is correct |
5 |
Correct |
1 ms |
592 KB |
Output is correct |
6 |
Correct |
3 ms |
592 KB |
Output is correct |
7 |
Correct |
3 ms |
592 KB |
Output is correct |
8 |
Correct |
19 ms |
592 KB |
Output is correct |
9 |
Correct |
4 ms |
592 KB |
Output is correct |
10 |
Correct |
4 ms |
592 KB |
Output is correct |
11 |
Correct |
16 ms |
764 KB |
Output is correct |
12 |
Correct |
24 ms |
916 KB |
Output is correct |
13 |
Correct |
28 ms |
820 KB |
Output is correct |
14 |
Correct |
68 ms |
848 KB |
Output is correct |
15 |
Correct |
24 ms |
856 KB |
Output is correct |
16 |
Execution timed out |
3067 ms |
696 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
584 KB |
Output is correct |
2 |
Correct |
1 ms |
688 KB |
Output is correct |
3 |
Correct |
3 ms |
592 KB |
Output is correct |
4 |
Correct |
2 ms |
592 KB |
Output is correct |
5 |
Correct |
1 ms |
592 KB |
Output is correct |
6 |
Correct |
3 ms |
592 KB |
Output is correct |
7 |
Correct |
3 ms |
592 KB |
Output is correct |
8 |
Correct |
19 ms |
592 KB |
Output is correct |
9 |
Correct |
4 ms |
592 KB |
Output is correct |
10 |
Correct |
4 ms |
592 KB |
Output is correct |
11 |
Correct |
16 ms |
764 KB |
Output is correct |
12 |
Correct |
24 ms |
916 KB |
Output is correct |
13 |
Correct |
28 ms |
820 KB |
Output is correct |
14 |
Correct |
68 ms |
848 KB |
Output is correct |
15 |
Correct |
24 ms |
856 KB |
Output is correct |
16 |
Execution timed out |
3067 ms |
696 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |