#include <bits/stdc++.h>
using namespace std;
const int MN = 200001;
using ll = long long;
ll n, q, A[MN], S[MN];
int main() {
cin >> n;
for(int i = 1; i <= n; ++i) {
cin >> A[i];
S[i] = 1;
while(!(A[i] & 1)) {
A[i] >>= 1;
S[i] <<= 1;
}
S[i] += S[i - 1];
}
cin >> q;
for(int i = 1; i <= q; ++i) {
ll p;
cin >> p;
int st = 1, dr = n, mij;
while(st < dr) {
mij = (st + dr) / 2;
if(S[mij] < p) st = mij + 1;
else dr = mij;
}
cout << A[st] << "\n";
}
return 0;
}
# |
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 |
72 ms |
3288 KB |
Output is correct |
4 |
Correct |
202 ms |
1308 KB |
Output is correct |
5 |
Correct |
284 ms |
3784 KB |
Output is correct |
6 |
Correct |
147 ms |
3088 KB |
Output is correct |
7 |
Correct |
327 ms |
3732 KB |
Output is correct |
8 |
Correct |
292 ms |
3796 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 |
312 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 |
72 ms |
3288 KB |
Output is correct |
4 |
Correct |
202 ms |
1308 KB |
Output is correct |
5 |
Correct |
284 ms |
3784 KB |
Output is correct |
6 |
Correct |
147 ms |
3088 KB |
Output is correct |
7 |
Correct |
327 ms |
3732 KB |
Output is correct |
8 |
Correct |
292 ms |
3796 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 |
312 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
2 ms |
340 KB |
Output is correct |
23 |
Correct |
173 ms |
3088 KB |
Output is correct |
24 |
Correct |
157 ms |
5140 KB |
Output is correct |
25 |
Correct |
330 ms |
8700 KB |
Output is correct |
26 |
Correct |
198 ms |
5544 KB |
Output is correct |
27 |
Correct |
168 ms |
5452 KB |
Output is correct |
28 |
Correct |
353 ms |
9132 KB |
Output is correct |
29 |
Correct |
358 ms |
8628 KB |
Output is correct |
30 |
Correct |
229 ms |
3704 KB |
Output is correct |
31 |
Correct |
361 ms |
9156 KB |
Output is correct |