#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define f first
#define s second
#define ve vector
#define pb push_back
int n;
int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>n;
int m;
int N=n;
ve<pii>v;
while(n--){
int x;
cin>>x;
int c=1;
while(x%2==0){
x/=2;
c*=2;
}
v.pb({x,c});
}
cin>>m;
ve<int>pf(N,0);
pf[0]=v[0].s;
for(int i=1;i<N;i++){
pf[i]=pf[i-1]+v[i].s;
}
while(m--){
int x;
cin>>x;
int res=1e18;
int mi=-1,ma=N,me;
while(ma-mi!=1){
me=(ma+mi)/2;
if(pf[me]>=x){
res=v[me].f;
ma= me;
}
else mi=me;
}
cout<<res<<"\n";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |