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;
using ll = long long;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
vector <ll> a(n+1);
for (int i = 1; i <= n; i++)
cin >> a[i];
vector <ll> pfx(n+1);
vector <ll> val(n+1);
ll cnt = 0;
for (int i = 1; i <= n; i++) {
ll tp = 1;
ll tp2 = a[i];
while (tp2 % 2 == 0) {
tp *= 2;
tp2 /= 2;
}
cnt += tp;
pfx[i] = cnt;
val[i] = tp2;
}
int q;
cin >> q;
while (q--) {
ll x;
cin >> x;
auto it = lower_bound(pfx.begin(), pfx.end(), x) - pfx.begin();
cout << val[it] << '\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... |