#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define st first
#define nd second
#define pb push_back
const int maxn = 2e5+7;
int liczby[maxn];
int koncowy[maxn];
ll sumy[maxn];
int binsearchh(int pocz,int kon,ll val){
int sro;
while(pocz < kon){
sro = (pocz+kon)/2;
if(sumy[sro] < val){
pocz = sro+1;
}
else{
kon = sro;
}
}
return pocz;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin>>n;
ll a,mnoznik;
for(int i=1;i<=n;i++){
cin>>a;
mnoznik = 1;
liczby[i] = a;
sumy[i] = sumy[i-1];
while(true){
if(a%2 == 1){
sumy[i] += mnoznik;
koncowy[i] = a;
break;
}
else{
mnoznik *= 2;
a/=2;
}
}
}
ll q,x;
cin>>q;
while(q--){
cin>>a;
x = binsearchh(0,n,a);
cout<<koncowy[x]<<"\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... |