#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 i = 0; i < m; i++) {
cin >> l >> r >> k;
int a[n];
for (int j = 0; j < n; j++) {
a[j] = arr[j];
}
int j = l - 1;
bool p = 1;
while (j < r) {
while (j + 1 < r && a[j] <= a[j + 1]) {
j++;
}
j++;
if (j == r) {
break;
}
int x = j;
while (j >= l && a[j] < a[j - 1] && a[j] + a[j - 1] <= k) {
a[j] += a[j - 1];
a[j - 1] = a[j] - a[j - 1];
a[j] -= a[j - 1];
j--;
}
if (j - 1 >= l) {
for (int b = 0; b < n; b++) {
cout << a[b] << " ";
}
p = 0;
break;
}
j = x;
}
if (p) {
cout << "1\n";
}
}
}
int main() {
int t = 1;
// cin >> t;
while (t--) {
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3030 ms |
262144 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3077 ms |
150264 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |