#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
int n, q;
cin >> n;
int a[n];
for(int i=0; i<n; i++) cin >> a[i];
vector<pair<int, int> > v;
for(int i=0; i<n; i++) {
int x = a[i], count = 0;
while(x%2==0) {
x/=2;
count++;
}
v.push_back(make_pair(x, 1<<count));
}
cin >> q;
int i = 0, count = 0;
while(q--) {
int x;
cin >> x;
while(count+v[i].second < x) {
count += v[i].second;
i++;
}
cout << v[i].first << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
18 ms |
3244 KB |
Output is correct |
4 |
Correct |
27 ms |
1328 KB |
Output is correct |
5 |
Correct |
42 ms |
3268 KB |
Output is correct |
6 |
Correct |
28 ms |
3152 KB |
Output is correct |
7 |
Correct |
43 ms |
3280 KB |
Output is correct |
8 |
Correct |
43 ms |
3264 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
18 ms |
3244 KB |
Output is correct |
4 |
Correct |
27 ms |
1328 KB |
Output is correct |
5 |
Correct |
42 ms |
3268 KB |
Output is correct |
6 |
Correct |
28 ms |
3152 KB |
Output is correct |
7 |
Correct |
43 ms |
3280 KB |
Output is correct |
8 |
Correct |
43 ms |
3264 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
18 |
Halted |
0 ms |
0 KB |
- |