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;
#define int long long
#define pii pair<long long, long long>
#define fr first
#define se second
int32_t main() {
int n;
cin >> n;
vector<int> v(n);
vector<pii> g(n);
for (int i = 0; i < n; i++) {
cin >> v[i];
int qtd = 1;
while (!(v[i] & 1LL)) {
v[i] >>= 1;
qtd <<= 1;
}
g[i] = {v[i], qtd};
}
int q;
cin >> q;
vector<pii> queries(q);
for (int i = 0; i < q; i++) {
int x;
cin >> x;
queries[i] = {x, i};
}
sort(queries.begin(), queries.end(), greater<pii>());
vector<int> ans(q);
int qtd = 0;
for (int i = 0; i < n; i++) {
qtd += g[i].se;
while (!queries.empty() && (qtd >= queries.back().fr)) {
ans[queries.back().se] = g[i].fr;
queries.pop_back();
}
}
for (auto u : ans) cout << u << "\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... |