Submission #1041178

#TimeUsernameProblemLanguageResultExecution timeMemory
1041178SoulKnightIntercastellar (JOI22_ho_t1)C++17
100 / 100
53 ms10960 KiB
#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define ln '\n'

const int N = 2e5 + 5;
ll n, a[N];
vector<ll> pfx, val;

void solve(){
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    pfx.push_back(0);
    val.push_back(-1);

    for (int i = 0; i < n; i++){
        int cnt = 0;
        ll x = a[i];
        while (x % 2 == 0) {cnt++; x /= 2;}
        pfx.push_back((1LL << cnt));
        val.push_back(x);

        // cout << cnt << ' ' << x << ln;
    }
    for (int i = 1; i < (int)pfx.size(); i++) pfx[i] += pfx[i-1];

    int q; cin >> q;
    while (q--){
        ll x; cin >> x;
        int j = lower_bound(pfx.begin(), pfx.end(), x) - pfx.begin();
        cout << val[j] << ln;
    }




}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    // int TT; cin >> TT;
    // while (TT--) {solve();}

    solve();

}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...