#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e5 + 7;
int n, q, a[N];
vector<int> g[101];
signed main () {
ios_base::sync_with_stdio(NULL);
cin.tie(0), cout.tie(0);
cin >> n >> q;
int lol = 0;
for (int i = 1; i <= n; i++) {
cin >> a[i];
g[lol].push_back(a[i]);
}
while (lol <= 100) {
lol++;
int l = 0, r = n/2;
while (l < n/2 || r < n) {
if (l == n/2) {
g[lol].push_back(g[lol-1][r]);
r++;
continue;
}
if (r == n) {
g[lol].push_back(g[lol-1][l]);
l++;
continue;
}
if (g[lol-1][l] <= g[lol-1][r]) {
g[lol].push_back(g[lol-1][l]);
l++;
} else {
g[lol].push_back(g[lol-1][r]);
r++;
}
}
if (g[lol] == g[lol-1]) break;
}
while (q--) {
int i, j;
cin >> i >> j;
cout << g[min(lol, i)][j-1] << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
2132 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
10 ms |
3812 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
161 ms |
163428 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
2132 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |