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 ln '\n'
const int N = 2e5 + 5;
ll n, a[N];
vector<ll> pfx, val;
void solve(){
cin >> n;
for (int i = 0; i < n; i++) cin >> a[i];
pfx.push_back(0);
val.push_back(-1);
for (int i = 0; i < n; i++){
int cnt = 0;
ll x = a[i];
while (x % 2 == 0) {cnt++; x /= 2;}
pfx.push_back((1LL << cnt));
val.push_back(x);
// cout << cnt << ' ' << x << ln;
}
for (int i = 1; i < (int)pfx.size(); i++) pfx[i] += pfx[i-1];
int q; cin >> q;
while (q--){
ll x; cin >> x;
int j = lower_bound(pfx.begin(), pfx.end(), x) - pfx.begin();
cout << val[j] << ln;
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// int TT; cin >> TT;
// while (TT--) {solve();}
solve();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |