# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
871125 | Marco_Escandon | Intercastellar (JOI22_ho_t1) | C++11 | 445 ms | 10836 KiB |
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;
typedef long long ll;
struct st{
vector<ll> abi;
void update(ll a,ll b)
{
for(a; a<abi.size(); a+=(a&-a))
{
abi[a]+=b;
}
}
ll query(ll a)
{
ll s=0;
for(a; a>0; a-=(a&-a))
{
s+=abi[a];
}
return s;
}
st(ll n)
{
abi.resize(n*2);
}
};
int main()
{
ll n;
cin>>n;
ll cad[n+1];
st asd(n+1);
for(int i=1; i<=n; i++)
{
cin>>cad[i];
ll temp=0;
while(cad[i]%2==0)
{
cad[i]/=2;
temp++;
}
asd.update(i,pow(2,temp));
}
ll q;
cin>>q;
while(q--)
{
ll a=0, b=n+1;
ll en;
cin>>en;
//cout<<asd.query(en)<<" ";
while(abs(a-b)!=1)
{
ll m=(a+b)/2;
if(asd.query(m)>=en)
b=m;
else a=m;
}
cout<<cad[b]<<"\n";
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |