This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
t = min(t, 100);
cout << a[t][i - 1] << '\n';
}
return 0;
}
# | 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... |