제출 #1330493

#제출 시각아이디문제언어결과실행 시간메모리
1330493thondonIntercastellar (JOI22_ho_t1)C++17
100 / 100
58 ms5576 KiB
#include<bits/stdc++.h>
using namespace std;
#define ll long long

signed main(){
    cin.tie(0)->sync_with_stdio(0);
    int N,Q;
    ll A;
    vector<pair<ll,ll>> Index;

    cin>>N;

    while(N--){
        cin>>A;

        ll grow_rate=1;

        if(Index.empty()) Index.emplace_back(0,0);
        else Index.emplace_back(Index.back().first,0);

        while((A&1)==0){
            A/=2;
            grow_rate*=2;
        }

        Index.back().first+=grow_rate;
        Index.back().second=A;
    }

    cin>>Q;

    while(Q--){
        ll x;
        cin>>x;

        int l=0,r=Index.size()-1;
        ll ans=0;

        while(l<=r){
            int mid=(l+r)/2;

            if(x <= Index[mid].first){
                ans=Index[mid].second;
                r=mid-1;
            }else l=mid+1;
        }

        cout<<ans<<"\n";
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...