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 int64_t
signed main() {
cin.tie(0);
ios_base::sync_with_stdio(0);
int n; cin >> n;
vector<int> a(n);
for (int i = 0; i<n; i++) {
cin >> a[i];
}
vector<pair<int, int>> pieces; // amount, len
for (int i=0; i<n; i++) {
int len = a[i];
int amount = 1;
while (len%2==0) {
len = len/2;
amount *= 2;
}
if (pieces.empty()) pieces.push_back({amount, len});
else pieces.push_back({amount+pieces.back().first, len});
}
int q; cin >> q;
for (int i = 0; i<q; i++) {
int x; cin >> x;
cout << (*lower_bound(pieces.begin(), pieces.end(), pair<int, int>{x, 0})).second << "\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... |