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 <algorithm>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
using pli = pair<ll,int>;
const char el = '\n';
int main() {
ios_base::sync_with_stdio(false), cin.tie(nullptr);
int n;
cin >> n;
vector<pli> PL; // position, length
ll cur_pos = 1LL;
for(int i=0, a, b, div; i<n; i++) {
cin >> a;
b = a;
div = 1;
while((b&1)==0) {
b >>= 1;
div <<= 1;
}
PL.push_back({cur_pos,a/div});
cur_pos += div;
}
int q;
cin >> q;
int pos;
ll x;
while(q--) {
cin >> x;
auto f = [&] (pli& pl) { return x>=pl.first; };
pos = distance(PL.begin(),
partition_point(PL.begin(),PL.end(),f));
pos--;
cout << PL[pos].second << el;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |