#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
ios_base::sync_with_stdio(0), cin.tie(0);
int n;
cin >> n;
vector<int> piececnt(n), ressz(n);
vector<int> cntprefsum(n);
for (int i = 0; i < n; ++i) {
int ai;
cin >> ai;
piececnt[i] = 1;
while (ai % 2 == 0) {
ai /= 2;
piececnt[i] *= 2;
}
ressz[i] = ai;
if (i + 1 < n)
cntprefsum[i + 1] = cntprefsum[i] + piececnt[i];
}
int q;
cin >> q;
while (q--) {
int xi;
cin >> xi;
int l = 0, r = n;
while (l + 1 < r) {
int m = (l + r) / 2;
if (cntprefsum[m] < xi)
l = m;
else
r = m;
}
cout << ressz[l] << '\n';
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
16 ms |
5508 KB |
Output is correct |
4 |
Correct |
30 ms |
2652 KB |
Output is correct |
5 |
Correct |
44 ms |
6864 KB |
Output is correct |
6 |
Correct |
24 ms |
5468 KB |
Output is correct |
7 |
Correct |
53 ms |
6996 KB |
Output is correct |
8 |
Correct |
41 ms |
7132 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
464 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
508 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
16 ms |
5508 KB |
Output is correct |
4 |
Correct |
30 ms |
2652 KB |
Output is correct |
5 |
Correct |
44 ms |
6864 KB |
Output is correct |
6 |
Correct |
24 ms |
5468 KB |
Output is correct |
7 |
Correct |
53 ms |
6996 KB |
Output is correct |
8 |
Correct |
41 ms |
7132 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
464 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
508 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
24 ms |
3276 KB |
Output is correct |
24 |
Correct |
28 ms |
6228 KB |
Output is correct |
25 |
Correct |
53 ms |
10160 KB |
Output is correct |
26 |
Correct |
37 ms |
6224 KB |
Output is correct |
27 |
Correct |
33 ms |
6484 KB |
Output is correct |
28 |
Correct |
62 ms |
10112 KB |
Output is correct |
29 |
Correct |
59 ms |
9552 KB |
Output is correct |
30 |
Correct |
30 ms |
3920 KB |
Output is correct |
31 |
Correct |
61 ms |
9808 KB |
Output is correct |