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;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
vector<int>v = {0};
vector<long long>pref(n + 1);
for(int i = 1;i <= n;++i){
int a;
cin >> a;
int cpy = a, cnt = 1;
while(cpy % 2 == 0){
cpy /= 2;
}
cnt = a / cpy;
v.push_back(cpy);
pref[i] = pref[i - 1] + cnt;
}
int q;
cin >> q;
while(q--){
long long x;
cin >> x;
int l = 1, r = n, ans = -1;
while(l <= r){
int mid = (l + r) >> 1;
if(pref[mid] >= x){
ans = mid;
r = mid - 1;
}
else{
l = mid + 1;
}
}
cout << v[ans] << '\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... |