#include <bits/stdc++.h>
using namespace std;
int main () {
ios_base::sync_with_stdio(false); cin.tie(0);
int n, q, x;
vector <int> v;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> x;
vector<int> stk = {x};
vector<int> v2;
while (stk.size()) {
int x = stk.back(); stk.pop_back();
if (x % 2) v2.push_back(x);
else {
stk.push_back(x / 2);
stk.push_back(x / 2);
}
}
reverse(v2.begin(), v2.end());
for (int x : v2) v.push_back(x);
}
cin >> q;
while (q--) {
cin >> x;
cout << v[x - 1] << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
31 ms |
3152 KB |
Output is correct |
4 |
Correct |
24 ms |
2264 KB |
Output is correct |
5 |
Correct |
54 ms |
4548 KB |
Output is correct |
6 |
Correct |
46 ms |
6100 KB |
Output is correct |
7 |
Correct |
56 ms |
6564 KB |
Output is correct |
8 |
Correct |
79 ms |
9668 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Runtime error |
510 ms |
524288 KB |
Execution killed with signal 9 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
31 ms |
3152 KB |
Output is correct |
4 |
Correct |
24 ms |
2264 KB |
Output is correct |
5 |
Correct |
54 ms |
4548 KB |
Output is correct |
6 |
Correct |
46 ms |
6100 KB |
Output is correct |
7 |
Correct |
56 ms |
6564 KB |
Output is correct |
8 |
Correct |
79 ms |
9668 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Runtime error |
510 ms |
524288 KB |
Execution killed with signal 9 |
12 |
Halted |
0 ms |
0 KB |
- |