This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<iostream>
using namespace std;
long long ciasta[200008][2];
int binsearch(long long x, int n){
int p=0; int k = n-1;
while(p!=k){
int mid=(p+k)/2;
if(ciasta[mid][0]==x){
return (mid);
}
else{
if(ciasta[mid][0]>x){
k = mid;
}
else{
p=mid+1;
}
}
}
return(k);
}
void dwoj(int a, int i){
unsigned int odp=1;
while(a%2==0){
odp=odp*2;
a=a/2;
}
ciasta[i][0]=odp;
ciasta[i][1]=a;
}
int main(){
long long n, q, a; cin >> n;
for(int i=0; i<n; i++){
cin >> a;
dwoj(a, i);
}
for(int i=1; i<n; i++){
ciasta[i][0]+=ciasta[i-1][0];
}
cin >> q;
long long x;
for(int i=0; i<q; i++){
cin >> x;
cout << ciasta[binsearch(x, n)][1]<<"\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |