#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<pair<int, int>> v(n);
for (int i = 0; i < n; i++) {
cin >> v[i].first;
v[i].second = 1;
while (!bool(v[i].first & 1)) {
v[i].first >>= 1;
v[i].second <<= 1;
}
}
int q;
cin >> q;
int ptr = 0;
long long ps = 0;
while (q--) {
long long x;
cin >> x;
while (x - ps > v[ptr].second) {
ps += v[ptr].second;
ptr++;
}
cout << v[ptr].first << endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
300 KB |
Output is correct |
3 |
Correct |
82 ms |
2380 KB |
Output is correct |
4 |
Correct |
229 ms |
1960 KB |
Output is correct |
5 |
Correct |
373 ms |
3908 KB |
Output is correct |
6 |
Correct |
163 ms |
2636 KB |
Output is correct |
7 |
Correct |
345 ms |
3984 KB |
Output is correct |
8 |
Correct |
320 ms |
4036 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 |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
304 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
2 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
3 ms |
212 KB |
Output is correct |
12 |
Correct |
4 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
308 KB |
Output is correct |
14 |
Correct |
3 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
300 KB |
Output is correct |
3 |
Correct |
82 ms |
2380 KB |
Output is correct |
4 |
Correct |
229 ms |
1960 KB |
Output is correct |
5 |
Correct |
373 ms |
3908 KB |
Output is correct |
6 |
Correct |
163 ms |
2636 KB |
Output is correct |
7 |
Correct |
345 ms |
3984 KB |
Output is correct |
8 |
Correct |
320 ms |
4036 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 |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
304 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
2 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
3 ms |
212 KB |
Output is correct |
20 |
Correct |
4 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
308 KB |
Output is correct |
22 |
Correct |
3 ms |
336 KB |
Output is correct |
23 |
Correct |
199 ms |
2732 KB |
Output is correct |
24 |
Correct |
178 ms |
4072 KB |
Output is correct |
25 |
Correct |
394 ms |
7180 KB |
Output is correct |
26 |
Correct |
228 ms |
4528 KB |
Output is correct |
27 |
Correct |
219 ms |
4464 KB |
Output is correct |
28 |
Correct |
415 ms |
7644 KB |
Output is correct |
29 |
Correct |
420 ms |
7100 KB |
Output is correct |
30 |
Correct |
271 ms |
3424 KB |
Output is correct |
31 |
Correct |
415 ms |
7596 KB |
Output is correct |