#include <bits/stdc++.h>
using namespace std;
#define ll long long
int a[1005][1005];
int main() {
ios_base::sync_with_stdio(0), cin.tie(0);
int n, q;
cin >> n >> q;
for (int i = 0; i < n; i++) {
cin >> a[0][i];
}
for (int j = 1; j <= n; j++) {
int ptr1 = 0, ptr2 = n / 2;
for (int i = 0; i < n; i++) {
if (ptr1 == n / 2 || (ptr2 < n && a[j - 1][ptr2] < a[j - 1][ptr1])) {
a[j][i] = a[j - 1][ptr2++];
} else {
a[j][i] = a[j - 1][ptr1++];
}
}
}
for (int j = 0; j <= n; j++) {
for (int i = 0; i < n; i++) {
cout << a[j][i] << ' ';
}
cout << '\n';
}
while (q--) {
int t, i;
cin >> t >> i;
cout << a[t][i - 1] << '\n';
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
54 ms |
12500 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
172 ms |
9956 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
96 ms |
8832 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
54 ms |
12500 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |