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 ll long long
#define fi first
#define se second
#define p(x,y) pair<ll,ll>(x,y)
#define BIT(i,x) ((x>>i)&1)
#define MASK(x) (1<<x)
#define ld long double
#define __builtin_popcount __builtin_popcountll
#define pll pair<ll,ll>
template<class T1,class T2>
bool maximize(T1 &x,const T2 &y)
{
if(x<y)
{
x=y;
return 1;
}
return 0;
}
template<class T1,class T2>
bool minimize(T1 &x,const T2 &y)
{
if(x>y)
{
x=y;
return 1;
}
return 0;
}
void online()
{
std::ios_base::sync_with_stdio(0);
cin.tie(0);
// #ifndef ONLINE_JUDGE
// freopen("input.INP","r",stdin);
// freopen("output.OUT","w",stdout);
// #endif // ONLINE_JUDGE
}
const ll N=1e7+10,M=1e9+7;
ll a[N],b[N],n;
int main()
{
online();
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a[i];
b[i]=1;
while(a[i]%2==0) b[i]*=2,a[i]/=2;
b[i]+=b[i-1];
}
ll q;
cin>>q;
while(q--)
{
ll x;
cin>>x;
ll base=0,d=n/2+1;
while(d)
{
while(base+d<=n&&b[base+d]<x) base+=d;
d/=2;
}
base++;
cout<<a[base]<<'\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... |