이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<iostream>
using namespace std;
#define int long long
int teraz[300000];
int drzewo[1000000];
int pot=1;
int zap(int x,int co)
{
if(x>pot)
return teraz[x-pot];
if(drzewo[x*2]>=co)
return zap(x*2,co);
else return zap(x*2+1,co-drzewo[x*2]);
}
int32_t main()
{
cin.tie(0);
cout.tie(0);
ios_base::sync_with_stdio(0);
int n,x;
cin>>n;
while(pot<=n)
pot*=2;
pot--;
for(int i=1;i<=n;i++)
{
cin>>x;
int ile=1;
int pom=x;
while(pom%2==0)
{
ile*=2;
pom/=2;
}
drzewo[i+pot]=ile;
teraz[i]=x/ile;
}
for(int i=pot;i>=1;i--)
drzewo[i]=drzewo[i*2]+drzewo[i*2+1];
int zapp;
cin>>zapp;
while(zapp--)
{
cin>>x;
cout<<zap(1,x)<<"\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... |