#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3,unroll-loops")
using namespace std;
#define int long long
#define pii pair<int,int>
#define ff first
#define ss second
#define sp << " " <<
#define all(cont) cont.begin(),cont.end()
#define vi vector<int>
const int inf = 1e17,N = 2e6+1,MOD = (1LL<<61)-1,B = 23;
void solve() {
int n;
cin >> n;
vi a(n+1);
vector<pii> ps;
for (int i=1;i<=n;i++) {
cin >> a[i];
int ctz = __builtin_ctz(a[i]);
ps.push_back({(1LL<<ctz),a[i]/(1LL<<ctz)});
}
int sm = 0;
for (auto& it : ps) {
it.ff+=sm;
sm=it.ff;
}
int q;
cin >> q;
while (q--) {
int k;
cin >> k;
int l = 0;
int r = ps.size()-1;
while (l<=r) {
int m = (l+r) >> 1;
if (k > ps[m].ff) l = m+1;
else r = m-1;
}
cout << ps[r+1].ss << '\n';
}
}
int32_t main() {
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#ifdef Dodi
freopen("in.txt","r",stdin);
freopen("out.txt","w",stdout);
#endif
int t = 1;
//cin >> t;
while (t --> 0) 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... |