#include <bits/stdc++.h>
using ll = long long;
typedef std::pair<ll,ll> pll;
int main()
{
std::ios::sync_with_stdio(false);
std::cin.tie(0);
std::cout.tie(0);
int N;
std::cin>>N;
ll seg[N]={};
ll val[N];
for(int i=0;i!=N;++i){
ll x;
std::cin>>x;
ll uns=0;
while(!(x%2)){
++uns;
x/=2;
}
ll vezes = 1LL<<uns;
if(i)seg[i]=seg[i-1];
seg[i]+=vezes;
val[i]=x;
}
int Q;
std::cin>>Q;
for(int i=0;i!=Q;++i){
ll X;
std::cin>>X;
ll l=0,r=N-1;
while(l<r){
ll m = (l+r)/2;
if(seg[m]>=X){
r=m;
}else l=m+1;
}
std::cout<<val[l]<<"\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
23 ms |
3952 KB |
Output is correct |
4 |
Correct |
43 ms |
2316 KB |
Output is correct |
5 |
Correct |
54 ms |
5512 KB |
Output is correct |
6 |
Correct |
28 ms |
4052 KB |
Output is correct |
7 |
Correct |
49 ms |
5540 KB |
Output is correct |
8 |
Correct |
49 ms |
5572 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
316 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
320 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
324 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
324 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 |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
23 ms |
3952 KB |
Output is correct |
4 |
Correct |
43 ms |
2316 KB |
Output is correct |
5 |
Correct |
54 ms |
5512 KB |
Output is correct |
6 |
Correct |
28 ms |
4052 KB |
Output is correct |
7 |
Correct |
49 ms |
5540 KB |
Output is correct |
8 |
Correct |
49 ms |
5572 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
316 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
320 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
324 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
324 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
27 ms |
2976 KB |
Output is correct |
24 |
Correct |
38 ms |
5180 KB |
Output is correct |
25 |
Correct |
78 ms |
8756 KB |
Output is correct |
26 |
Correct |
45 ms |
5476 KB |
Output is correct |
27 |
Correct |
43 ms |
5468 KB |
Output is correct |
28 |
Correct |
82 ms |
9108 KB |
Output is correct |
29 |
Correct |
100 ms |
8656 KB |
Output is correct |
30 |
Correct |
39 ms |
3680 KB |
Output is correct |
31 |
Correct |
81 ms |
9124 KB |
Output is correct |