#include<bits/stdc++.h>
using namespace std;
#define ioss ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
#define tup tuple<int, int, int>
#define pii pair<int, int>
#define fi first
#define se second
#define pub push_back
#define pob pop_back
int n, arr[200004], q;
signed main() {
ioss;
cin >> n;
vector<int> range(n+2);
for(int i = 1; i <= n; i++) {
cin >> arr[i];
int cnt = 1;
while(arr[i]%2 == 0) arr[i] /= 2, cnt *= 2;
range[i] = range[i-1]+cnt;
}
cin >> q;
int idx = 1;
for(int i = 1; i <= q; i++) {
int x; cin >> x;
while(range[idx] < x) idx++;
cout << arr[idx] << endl;
}
}
# |
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 |
50 ms |
3312 KB |
Output is correct |
4 |
Correct |
164 ms |
1372 KB |
Output is correct |
5 |
Correct |
222 ms |
3740 KB |
Output is correct |
6 |
Correct |
111 ms |
3020 KB |
Output is correct |
7 |
Correct |
221 ms |
3728 KB |
Output is correct |
8 |
Correct |
229 ms |
3804 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 |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
2 ms |
340 KB |
Output is correct |
12 |
Correct |
2 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
2 ms |
340 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 |
50 ms |
3312 KB |
Output is correct |
4 |
Correct |
164 ms |
1372 KB |
Output is correct |
5 |
Correct |
222 ms |
3740 KB |
Output is correct |
6 |
Correct |
111 ms |
3020 KB |
Output is correct |
7 |
Correct |
221 ms |
3728 KB |
Output is correct |
8 |
Correct |
229 ms |
3804 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 |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
2 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
2 ms |
340 KB |
Output is correct |
20 |
Correct |
2 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
2 ms |
340 KB |
Output is correct |
23 |
Correct |
153 ms |
1952 KB |
Output is correct |
24 |
Correct |
107 ms |
3328 KB |
Output is correct |
25 |
Correct |
253 ms |
5308 KB |
Output is correct |
26 |
Correct |
145 ms |
2928 KB |
Output is correct |
27 |
Correct |
125 ms |
3044 KB |
Output is correct |
28 |
Correct |
247 ms |
4516 KB |
Output is correct |
29 |
Correct |
251 ms |
3728 KB |
Output is correct |
30 |
Correct |
189 ms |
1340 KB |
Output is correct |
31 |
Correct |
284 ms |
4300 KB |
Output is correct |