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;
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
int N; cin >> N;
vector<int> A(N);
for (int i = 0; i < N; ++i) {
cin >> A[i];
}
function<int(int)> rec = [&](int x) {
if (x & 1) {
return 1;
}
return 2 * rec(x / 2);
};
vector<pair<int, long long>> B;
for (int i = 0; i < N; ++i) {
int x = A[i];
while (x % 2 == 0) {
x /= 2;
}
B.push_back({x, rec(A[i])});
}
for (int i = 1; i < N; ++i) {
B[i].second += B[i - 1].second;
}
int Q; cin >> Q;
while (Q--) {
long long X; cin >> X;
int L = 0, R = N - 1, res = -1;
while (L <= R) {
int md = (L + R) / 2;
if (B[md].second >= X) {
res = md;
R = md - 1;
} else {
L = md + 1;
}
}
cout << B[res].first << "\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... |