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;
typedef long long ll;
const int MAXN = 2e5 + 25;
pair <ll, ll> a[MAXN];
int n, q;
void solve () {
cin >> n;
for (int i = 1; i <= n; i++) {
ll x; cin >> x;
ll c = 0;
while (!(x & 1)) {
c++; x /= 2;
}
a[i] = {(1ll << c) + a[i - 1].first, x};
}
cin >> q;
while (q--) {
ll x; cin >> x;
int l = 1, r = n, ans = -1;
while (l <= r) {
int mid = (l + r) / 2;
if (a[mid].first >= x) {
r = mid - 1; ans = mid;
} else {
l = mid + 1;
}
}
cout << a[ans].second << '\n';
}
}
int main () {
ios::sync_with_stdio(0); cin.tie(0);
int t = 1; //cin >> t;
while (t--) 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... |