Submission #1180970

#TimeUsernameProblemLanguageResultExecution timeMemory
1180970Fikrat_AsadzadehIntercastellar (JOI22_ho_t1)C++20
100 / 100
47 ms5444 KiB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define FORI(i, n) for(ll i = 0; i < n; i++)
#define FOR(i, n) for(ll i = 1; i <= n; i++)
typedef vector < ll > vl; 
typedef set < ll > setl;
#define ff first
#define ss second    
#define all(v) v.begin(), v.end() 
#define pll pair<ll, ll> 
#define db double
#define nll cout << "\n"
#define nl "\n"
#define sync ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
ll poww(ll a, ll b){
    ll res = 1;
    while(b){
        if(b & 1)res *= a;
        a *= a;
        b >>= 1;
    }
    return res;
}
const ll mod =  998244353;
const int sz = 2e5 + 23 ;
const long long imax = LLONG_MAX;
ll n, m, k, res, q, x, y;
ll ind[sz], a[sz];
pll bolen(ll x){
    ll pw = 1;
    ll cnt = 1;
    while(1){
        if(x % 2 == 1){
            return {x, pw};
        } 
        else pw *= 2; x /= 2;
    }
}
void solve(){
    cin >> n;
    FOR(i, n){
        cin >> a[i];
    }
    FOR(i, n){
        ind[i] = ind[i - 1];
        pll c = bolen(a[i]);
        ind[i] += c.ss;
        a[i] = c.ff;
    }
    cin >> q;
    while(q--){
        cin >> x;
        ll nd = lower_bound(ind + 1, ind + 1 + n, x) - ind;
        cout << a[nd] << nl;
    }
}
//IOI rice hub
signed main(){      
    // freopen("input.txt","r",stdin);a
    // freopen("output.txt","w",stdout);
    sync;
    ll t = 1;
    // cin >> t;
    while(t--){
        solve();
    }   
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...