This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/**
____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N_MAX = 200000;
const int Q_MAX = 200000;
int N, Q;
ll A[N_MAX + 2];
ll pref[N_MAX + 2];
int main () {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> N;
for (int i = 1; i <= N; i++) {
cin >> A[i];
pref[i] = 1;
while (A[i] % 2 == 0) {
A[i] /= 2;
pref[i] *= 2;
}
pref[i] += pref[i - 1];
}
cin >> Q;
while (Q--) {
ll X;
cin >> X;
int l = 1, r = N;
while (l < r) {
int mid = (l + r) / 2;
if (X <= pref[mid]) {
r = mid;
} else {
l = mid + 1;
}
}
cout << A[l] << "\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... |