Submission #1340637

#TimeUsernameProblemLanguageResultExecution timeMemory
1340637mozkunIntercastellar (JOI22_ho_t1)C++20
100 / 100
53 ms5360 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
    cin.tie(nullptr)->sync_with_stdio(false);
    
    int n;
    cin >> n;

    vector<ll> val(n), cnt(n);

    for(int i = 0; i < n; i++){
        ll x;
        cin >> x;

        int k = 0;
        while(x % 2 == 0){
            x /= 2;
            k++;
        }

        val[i] = x;
        cnt[i] = (1ll << k);
    }

    for(int i = 1; i < n; i++){
        cnt[i] += cnt[i-1];
        if(cnt[i] > (ll)1e18) cnt[i] = (ll)1e18;
    }

    int q;
    cin >> q;

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

        int idx = lower_bound(cnt.begin(), cnt.end(), x) - cnt.begin();
        cout << val[idx] << '\n';
    }

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...