#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, q;
cin >> n >> q;
vector<vector<int>> key(1, vector<int>(n));
for(int i = 0; i < n; i++) {
cin >> key[0][i];
}
while (true) {
vector<int> a(n);
merge(key.back().begin(), key.back().begin() + n / 2, key.back().begin() + n / 2, key.back().end(), a.begin());
if (a == key.back()) break;
key.push_back(a);
}
while (q--) {
int t, i;
cin >> t >> i;
i--;
t = min(t, (int)key.size() - 1);
cout << key[t][i] << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
159 ms |
15956 KB |
Output is correct |
2 |
Correct |
155 ms |
12488 KB |
Output is correct |
3 |
Correct |
146 ms |
13140 KB |
Output is correct |
4 |
Correct |
144 ms |
10324 KB |
Output is correct |
5 |
Correct |
153 ms |
12116 KB |
Output is correct |
6 |
Correct |
143 ms |
10832 KB |
Output is correct |
7 |
Correct |
157 ms |
12136 KB |
Output is correct |
8 |
Correct |
166 ms |
10880 KB |
Output is correct |
9 |
Correct |
146 ms |
10616 KB |
Output is correct |
10 |
Correct |
144 ms |
10656 KB |
Output is correct |
11 |
Correct |
145 ms |
10836 KB |
Output is correct |
12 |
Correct |
146 ms |
9636 KB |
Output is correct |
13 |
Correct |
149 ms |
10324 KB |
Output is correct |
14 |
Correct |
149 ms |
11432 KB |
Output is correct |
15 |
Correct |
150 ms |
10668 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
133 ms |
9736 KB |
Output is correct |
18 |
Correct |
145 ms |
9664 KB |
Output is correct |
19 |
Correct |
0 ms |
344 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
314 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
318 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
159 ms |
15956 KB |
Output is correct |
2 |
Correct |
155 ms |
12488 KB |
Output is correct |
3 |
Correct |
146 ms |
13140 KB |
Output is correct |
4 |
Correct |
144 ms |
10324 KB |
Output is correct |
5 |
Correct |
153 ms |
12116 KB |
Output is correct |
6 |
Correct |
143 ms |
10832 KB |
Output is correct |
7 |
Correct |
157 ms |
12136 KB |
Output is correct |
8 |
Correct |
166 ms |
10880 KB |
Output is correct |
9 |
Correct |
146 ms |
10616 KB |
Output is correct |
10 |
Correct |
144 ms |
10656 KB |
Output is correct |
11 |
Correct |
145 ms |
10836 KB |
Output is correct |
12 |
Correct |
146 ms |
9636 KB |
Output is correct |
13 |
Correct |
149 ms |
10324 KB |
Output is correct |
14 |
Correct |
149 ms |
11432 KB |
Output is correct |
15 |
Correct |
150 ms |
10668 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
133 ms |
9736 KB |
Output is correct |
18 |
Correct |
145 ms |
9664 KB |
Output is correct |
19 |
Correct |
0 ms |
344 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Runtime error |
314 ms |
524288 KB |
Execution killed with signal 9 |
22 |
Halted |
0 ms |
0 KB |
- |