이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int dd[1002][1001];
int n, q;
int main () {
cin >> n >> q;
for (int i = 1; i <= n; i++) cin >> dd[0][i];
for (int i = 1; i <= n; i++) {
deque <int> a, b;
for (int j = 1; j <= n / 2; j++) a.push_back(dd[i - 1][j]);
for (int j = n / 2 + 1; j <= n; j++) b.push_back(dd[i - 1][j]);
int c = 0;
while (!a.empty() && !b.empty()) {
if (a.front() < b.front()) {
dd[i][++c] = a.front(); a.pop_front();
} else {
dd[i][++c] = b.front(); b.pop_front();
}
}
while (!a.empty()) dd[i][++c] = a.front(), a.pop_front();
while (!b.empty()) dd[i][++c] = b.front(), b.pop_front();
}
while (q--) {
int x, y; cin >> x >> y;
x = min(x, n);
cout << dd[x][y] << '\n';
}
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |