Submission #1144111

#TimeUsernameProblemLanguageResultExecution timeMemory
1144111Aryan_RainaIntercastellar (JOI22_ho_t1)C++20
100 / 100
48 ms5444 KiB
#include <bits/stdc++.h>

using namespace std;

#define int int64_t
#define ar array
#define all(v) begin(v), end(v)
#define allr(v) rbegin(v), rend(v)
#define pb push_back

const int INF = 1e10;

void solve() {  
    int n; cin >> n;
    vector<int> a(n),pf(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        pf[i] = 1;
        while (a[i] % 2 == 0) pf[i]*=2, a[i]/=2;
        if (i) pf[i] += pf[i-1];
    }

    int q; cin >> q;
    int ind = 0;
    while (q--) {
        int x; cin >> x;
        while (pf[ind] < x) ind++;
        cout << a[ind] << '\n';
    }
}  

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int 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...