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(false);
cin.tie(NULL);
cout.tie(NULL);
long long n,q,a,l,r,m;
cin >> n;
vector<long long> pr(1);
vector<long long> haha(0);
for(long long i = 0; i < n; i++) {
cin >> a;
pr.push_back(1);
while(a%2 == 0) {
a/=2;
pr[i+1]*=2;
}
haha.push_back(a);
}
for(long long i = 1; i <= n; i++) {
pr[i]+=pr[i-1];
}
cin >> q;
for(long long i = 0; i < q; i++) {
cin >> a;
l = 0;
r = n;
while(l < r) {
m = (l+r)/2;
if(pr[m] >= a) {
r = m;
}
else {
l = m+1;
}
}
cout << haha[l-1] << "\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... |