#include <bits/stdc++.h>
using namespace std;
/*
5 2
3 5 1 8 2
1 5 10
*/
void solve() {
int n, m, l, r, k;
cin >> n >> m;
int arr[n];
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
for (int b = 0; b < m; b++) {
cin >> l >> r >> k;
int a[n];
for (int i = 0; i < n; i++) {
a[i] = arr[i];
}
bool p = 1;
for (int i = l; i < r; i++) {
int x = a[i];
// x = 5
int j = i - 1;
// j = 0
while (j >= l - 1 && a[j] > x && a[j] + x <= k) {
a[j + 1] = a[j];
j--;
}
if (j >= l - 1 && a[j] > x) {
p = 0;
cout << "0\n";
break;
}
a[j + 1] = x;
}
if (p) {
cout << "1\n";
}
}
}
int main() {
int t = 1;
// cin >> t;
while (t--) {
solve();
}
}
# |
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 |
2 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
2 ms |
204 KB |
Output is correct |
7 |
Correct |
2 ms |
204 KB |
Output is correct |
8 |
Correct |
3 ms |
204 KB |
Output is correct |
9 |
Correct |
4 ms |
204 KB |
Output is correct |
10 |
Correct |
3 ms |
204 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 |
2 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
2 ms |
204 KB |
Output is correct |
7 |
Correct |
2 ms |
204 KB |
Output is correct |
8 |
Correct |
3 ms |
204 KB |
Output is correct |
9 |
Correct |
4 ms |
204 KB |
Output is correct |
10 |
Correct |
3 ms |
204 KB |
Output is correct |
11 |
Correct |
9 ms |
376 KB |
Output is correct |
12 |
Correct |
19 ms |
392 KB |
Output is correct |
13 |
Correct |
20 ms |
436 KB |
Output is correct |
14 |
Correct |
36 ms |
460 KB |
Output is correct |
15 |
Correct |
24 ms |
484 KB |
Output is correct |
16 |
Correct |
1294 ms |
432 KB |
Output is correct |
17 |
Execution timed out |
3064 ms |
396 KB |
Time limit exceeded |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3008 ms |
8192 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3065 ms |
1056 KB |
Time limit exceeded |
2 |
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 |
2 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
2 ms |
204 KB |
Output is correct |
7 |
Correct |
2 ms |
204 KB |
Output is correct |
8 |
Correct |
3 ms |
204 KB |
Output is correct |
9 |
Correct |
4 ms |
204 KB |
Output is correct |
10 |
Correct |
3 ms |
204 KB |
Output is correct |
11 |
Correct |
9 ms |
376 KB |
Output is correct |
12 |
Correct |
19 ms |
392 KB |
Output is correct |
13 |
Correct |
20 ms |
436 KB |
Output is correct |
14 |
Correct |
36 ms |
460 KB |
Output is correct |
15 |
Correct |
24 ms |
484 KB |
Output is correct |
16 |
Correct |
1294 ms |
432 KB |
Output is correct |
17 |
Execution timed out |
3064 ms |
396 KB |
Time limit exceeded |
18 |
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 |
2 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
2 ms |
204 KB |
Output is correct |
7 |
Correct |
2 ms |
204 KB |
Output is correct |
8 |
Correct |
3 ms |
204 KB |
Output is correct |
9 |
Correct |
4 ms |
204 KB |
Output is correct |
10 |
Correct |
3 ms |
204 KB |
Output is correct |
11 |
Correct |
9 ms |
376 KB |
Output is correct |
12 |
Correct |
19 ms |
392 KB |
Output is correct |
13 |
Correct |
20 ms |
436 KB |
Output is correct |
14 |
Correct |
36 ms |
460 KB |
Output is correct |
15 |
Correct |
24 ms |
484 KB |
Output is correct |
16 |
Correct |
1294 ms |
432 KB |
Output is correct |
17 |
Execution timed out |
3064 ms |
396 KB |
Time limit exceeded |
18 |
Halted |
0 ms |
0 KB |
- |