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()
{
long long n;
cin>>n;
long long niza[n];
for(long long i=0; i<n; i++)cin>>niza[i];
long long idx=0;
vector<pair<long long,long long> > v;
for(long long i=n-1; i>=0; i--)
{
if(niza[i]%2)
{
v.push_back({1,niza[i]});
idx++;
}
else
{
long long sob=1;
while(true)
{
niza[i]/=2;
sob*=2;
if(niza[i]%2)break;
}
v.push_back({sob,niza[i]});
idx+=sob;
}
}
reverse(v.begin(),v.end());
long long q;
cin>>q;
idx=0;
long long sum=0;
for(long long i=0; i<q; i++)
{
long long x;
cin>>x;
while(true)
{
if(sum+v[idx].first<x)
{
sum+=v[idx].first;
idx++;
}
else
{
cout<<v[idx].second<<endl;
break;
}
}
}
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... |