#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
const int N = 2e5 + 5;
ll a[N], pref[N];
int main() {
ios_base::sync_with_stdio(false); cin.tie(NULL);
int n, q;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
ll mult = 1;
while (a[i] % 2 == 0) a[i] /= 2, mult *= 2;
pref[i] = pref[i - 1] + mult;
}
cin >> q;
ll id = 0;
while (q--) {
ll x;
cin >> x;
while (pref[id] < x) id++;
cout << a[id] << "\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
15 ms |
3412 KB |
Output is correct |
4 |
Correct |
22 ms |
1344 KB |
Output is correct |
5 |
Correct |
40 ms |
3792 KB |
Output is correct |
6 |
Correct |
20 ms |
3020 KB |
Output is correct |
7 |
Correct |
35 ms |
3832 KB |
Output is correct |
8 |
Correct |
34 ms |
3788 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 |
340 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 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 |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
15 ms |
3412 KB |
Output is correct |
4 |
Correct |
22 ms |
1344 KB |
Output is correct |
5 |
Correct |
40 ms |
3792 KB |
Output is correct |
6 |
Correct |
20 ms |
3020 KB |
Output is correct |
7 |
Correct |
35 ms |
3832 KB |
Output is correct |
8 |
Correct |
34 ms |
3788 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 |
340 KB |
Output is correct |
15 |
Correct |
0 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
0 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 |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
20 ms |
1908 KB |
Output is correct |
24 |
Correct |
26 ms |
3284 KB |
Output is correct |
25 |
Correct |
48 ms |
5368 KB |
Output is correct |
26 |
Correct |
33 ms |
2860 KB |
Output is correct |
27 |
Correct |
31 ms |
2948 KB |
Output is correct |
28 |
Correct |
57 ms |
4532 KB |
Output is correct |
29 |
Correct |
55 ms |
3724 KB |
Output is correct |
30 |
Correct |
28 ms |
1316 KB |
Output is correct |
31 |
Correct |
56 ms |
4300 KB |
Output is correct |