#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
vector <ll> a(n+1);
for (int i = 1; i <= n; i++)
cin >> a[i];
vector <ll> pfx(n+1);
vector <ll> val(n+1);
ll cnt = 0;
for (int i = 1; i <= n; i++) {
ll tp = 1;
ll tp2 = a[i];
while (tp2 % 2 == 0) {
tp *= 2;
tp2 /= 2;
}
cnt += tp;
pfx[i] = cnt;
val[i] = tp2;
}
int q;
cin >> q;
while (q--) {
ll x;
cin >> x;
auto it = lower_bound(pfx.begin(), pfx.end(), x) - pfx.begin();
cout << val[it] << '\n';
}
}
# |
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 |
Correct |
14 ms |
4984 KB |
Output is correct |
4 |
Correct |
19 ms |
2908 KB |
Output is correct |
5 |
Correct |
35 ms |
7252 KB |
Output is correct |
6 |
Correct |
21 ms |
5468 KB |
Output is correct |
7 |
Correct |
42 ms |
7140 KB |
Output is correct |
8 |
Correct |
35 ms |
7252 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 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 |
348 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 |
# |
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 |
Correct |
14 ms |
4984 KB |
Output is correct |
4 |
Correct |
19 ms |
2908 KB |
Output is correct |
5 |
Correct |
35 ms |
7252 KB |
Output is correct |
6 |
Correct |
21 ms |
5468 KB |
Output is correct |
7 |
Correct |
42 ms |
7140 KB |
Output is correct |
8 |
Correct |
35 ms |
7252 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 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 |
348 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 |
19 ms |
3276 KB |
Output is correct |
24 |
Correct |
25 ms |
6488 KB |
Output is correct |
25 |
Correct |
46 ms |
10396 KB |
Output is correct |
26 |
Correct |
40 ms |
6484 KB |
Output is correct |
27 |
Correct |
28 ms |
6748 KB |
Output is correct |
28 |
Correct |
69 ms |
10924 KB |
Output is correct |
29 |
Correct |
87 ms |
10328 KB |
Output is correct |
30 |
Correct |
27 ms |
3924 KB |
Output is correct |
31 |
Correct |
59 ms |
10836 KB |
Output is correct |