Submission #1184083

#TimeUsernameProblemLanguageResultExecution timeMemory
1184083al95ireyizIntercastellar (JOI22_ho_t1)C++20
100 / 100
44 ms7048 KiB
//*** Bismillah ***//
// It's the evening of another day. And the end of mine...
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#if !defined(ONLINE_JUDGE) and !defined(EVAL)
#include "template/debug.h"
#else
#define d(x...)
#endif
#define ll long long
const ll INF = 1e9;
const ll INFL = 1e18;
const ll MOD = 1e9 + 7;
const ll maxn = 2e5 + 5;
ll n,m,k=0;
ll a[maxn], b[maxn], ps[maxn];
void _(){
    cin>>n;
    for(ll i=1;i<=n;i++){
        cin>>a[i];
        b[i] = 1;
        while(a[i] % 2 == 0) a[i] >>= 1, b[i] <<= 1;
    }
    for(ll i=1;i<=n;i++) ps[i] = ps[i-1] + b[i];
    cin>>m;
    for(ll i=1;i<=m;i++){
        ll x;
        cin>>x;
        ll l=1, r=n, cv;
        while(l<=r){
            ll md = (l+r)>>1;
            if(ps[md] >= x) r = md - 1, cv = md;
            else l = md + 1;
        }
        cout<<a[cv]<<'\n';
    }
}
signed main(){
    auto testcaseruntime=clock();
    cin.tie(0)->sync_with_stdio(0);
    ll t=1;
    // cin>>t;
    while(t--){
        _();
    }
    cerr<<"\n\033[1;31mTime: \033[1;30m"
        <<(double)(clock()-testcaseruntime)/1000000<<"\033[1;32m seconds\n";
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...