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<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define float double
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n;cin>>n;
vector<ll>v(n);for(int i=0;i<n;i++)cin>>v[i];
vector<pair<ll, ll>>vp;
for(int i=0;i<n;i++){
ll cnt(1);
ll x = v[i];
while(x%2==0){
cnt*=2;
x/=2;
}
vp.push_back({cnt, x});
}
vector<ll>pr(n+1);
for(int i=1;i<=n;i++)pr[i] = pr[i-1] + vp[i-1].first;
//for(int i=0;i<n;i++)cout<<vp[i].first<<" : "<<vp[i].second<<endl;
int Q;cin>>Q;
while(Q--){
ll x;cin>>x;
auto it = lower_bound(pr.begin(), pr.end(), x);
cout<<vp[it-pr.begin()-1].second<<endl;
}
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... |