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 int long long
signed main(){
//ios_base::sync_with_stdio(0); cin.tie(0);
int n; cin >> n;
vector<int> a(n);
for(int i = 0; i < n; i++) cin >> a[i];
int q; cin >> q;
vector<int> query(q);
for(int i = 0; i < q; i++) cin >> query[i];
vector<pair<int,int>> w;
for(int i = 0; i < n; i++){
if(a[i] % 2 != 0) w.emplace_back(a[i], 1);
else {
int t = 1;
while(a[i] % 2 == 0){
a[i] /= 2;
t <<= 1;
}
w.emplace_back(a[i], t);
}
}
vector<int> pr(w.size());
pr[0] = w[0].second;
for(int i = 1; i < n; i++) pr[i] = pr[i-1] + w[i].second;
for(int i = 0; i < q; i++){
int pos = lower_bound(pr.begin(), pr.end(), query[i]) - pr.begin();
cout << w[pos].first << '\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... |