#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<int> a(n);
vector<long long> p(n + 1);
for (int i = 0; i < n; i++) {
cin >> a[i];
int tz = __builtin_ctz(a[i]);
p[i + 1] = p[i] + (1 << tz);
a[i] >>= tz;
}
int q;
cin >> q;
while (q--) {
long long x;
cin >> x;
cout << a[lower_bound(p.begin(), p.end(), x) - p.begin() - 1] << '\n';
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
18 ms |
2588 KB |
Output is correct |
4 |
Correct |
28 ms |
1160 KB |
Output is correct |
5 |
Correct |
46 ms |
3100 KB |
Output is correct |
6 |
Correct |
25 ms |
2556 KB |
Output is correct |
7 |
Correct |
46 ms |
3012 KB |
Output is correct |
8 |
Correct |
46 ms |
3056 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
328 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
18 ms |
2588 KB |
Output is correct |
4 |
Correct |
28 ms |
1160 KB |
Output is correct |
5 |
Correct |
46 ms |
3100 KB |
Output is correct |
6 |
Correct |
25 ms |
2556 KB |
Output is correct |
7 |
Correct |
46 ms |
3012 KB |
Output is correct |
8 |
Correct |
46 ms |
3056 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 |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
328 KB |
Output is correct |
22 |
Correct |
1 ms |
332 KB |
Output is correct |
23 |
Correct |
26 ms |
2928 KB |
Output is correct |
24 |
Correct |
31 ms |
4656 KB |
Output is correct |
25 |
Correct |
67 ms |
8004 KB |
Output is correct |
26 |
Correct |
42 ms |
5088 KB |
Output is correct |
27 |
Correct |
37 ms |
4924 KB |
Output is correct |
28 |
Correct |
71 ms |
8328 KB |
Output is correct |
29 |
Correct |
71 ms |
7836 KB |
Output is correct |
30 |
Correct |
41 ms |
3532 KB |
Output is correct |
31 |
Correct |
72 ms |
8288 KB |
Output is correct |