#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 2e5;
ll v[N];
int main(){
ll n,q;
ll pt = 0,pt2 = 0;
ll tmp = -1;
cin>>n;
for(ll i = 0;i < n;i++){
cin>>v[i];
}
cin>>q;
for(ll i = 0;i < q;i++){
ll x;
cin>>x;
while(pt2 < n && pt < x){
///include next number
ll cnt = 1,nr2 = v[pt2];
while(nr2%2 == 0){
nr2/=2;
cnt*=2;
}
pt+=cnt;
tmp = nr2;
pt2++;
}
cout<<tmp<<'\n';
}
return 0;
}
/**
4
14 9 8 12
6
2 3 5 7 11 13
**/
# |
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 |
62 ms |
2576 KB |
Output is correct |
4 |
Correct |
179 ms |
1876 KB |
Output is correct |
5 |
Correct |
263 ms |
4184 KB |
Output is correct |
6 |
Correct |
139 ms |
2640 KB |
Output is correct |
7 |
Correct |
239 ms |
3920 KB |
Output is correct |
8 |
Correct |
243 ms |
4320 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 |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
452 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
2 ms |
344 KB |
Output is correct |
12 |
Correct |
2 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
448 KB |
Output is correct |
14 |
Correct |
2 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 |
62 ms |
2576 KB |
Output is correct |
4 |
Correct |
179 ms |
1876 KB |
Output is correct |
5 |
Correct |
263 ms |
4184 KB |
Output is correct |
6 |
Correct |
139 ms |
2640 KB |
Output is correct |
7 |
Correct |
239 ms |
3920 KB |
Output is correct |
8 |
Correct |
243 ms |
4320 KB |
Output is correct |
9 |
Correct |
0 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 |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
452 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
2 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
2 ms |
344 KB |
Output is correct |
20 |
Correct |
2 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
448 KB |
Output is correct |
22 |
Correct |
2 ms |
348 KB |
Output is correct |
23 |
Correct |
166 ms |
2900 KB |
Output is correct |
24 |
Correct |
126 ms |
4180 KB |
Output is correct |
25 |
Correct |
268 ms |
7336 KB |
Output is correct |
26 |
Correct |
176 ms |
4692 KB |
Output is correct |
27 |
Correct |
153 ms |
4492 KB |
Output is correct |
28 |
Correct |
336 ms |
7748 KB |
Output is correct |
29 |
Correct |
313 ms |
7248 KB |
Output is correct |
30 |
Correct |
231 ms |
3596 KB |
Output is correct |
31 |
Correct |
314 ms |
7508 KB |
Output is correct |