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>
#define int long long
using namespace std;
int n, q, temp;
vector<int> a, prefix;
signed main() {
cin >> n;
a = vector<int>(n), prefix = vector<int>(n);
for(int i = 0; i < n; i++) {
cin >> a[i];
temp = __builtin_ctz(a[i]);
a[i] /= (1 << temp);
prefix[i] = (1 << temp);
if(i > 0) prefix[i] += prefix[i - 1];
}
cin >> q;
while(q--) {
cin >> temp;
int l = 0, r = n, mid, ans = 0;
while(l<=r) {
mid = (l + r) / 2;
if(prefix[mid] < temp) {
ans = mid + 1;
l = mid + 1;
} else r = mid - 1;
}
cout << a[ans] << "\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... |