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;
const int MN = 200001;
using ll = long long;
ll n, q, A[MN], S[MN];
int main() {
cin >> n;
for(int i = 1; i <= n; ++i) {
cin >> A[i];
S[i] = 1;
while(!(A[i] & 1)) {
A[i] >>= 1;
S[i] <<= 1;
}
S[i] += S[i - 1];
}
cin >> q;
for(int i = 1; i <= q; ++i) {
ll p;
cin >> p;
int st = 1, dr = n, mij;
while(st < dr) {
mij = (st + dr) / 2;
if(S[mij] < p) st = mij + 1;
else dr = mij;
}
cout << A[st] << "\n";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |