Submission #981115

#TimeUsernameProblemLanguageResultExecution timeMemory
981115UltraFalconIntercastellar (JOI22_ho_t1)C++17
100 / 100
65 ms12380 KiB
#ifndef DEBUG
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2,abm,mmx,fma,popcnt")
#endif

#include <bits/stdc++.h>
#define int long long
using ll = long long;

using namespace std;

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

    int n; cin >> n;

    vector<int> a(n);
    for (auto &x : a) cin >> x;

    vector<int> pref(n+1, 0);
    vector<int> len(n);
    for (int i=0; i<n; i++) {
        int x = a[i];
        int cnt = 1;
        while (x%2==0) {
            cnt<<=1;
            x>>=1;
        }
        pref[i+1] = pref[i] + cnt;
        len[i] = x;
    }

    int q; cin >> q;

    vector<int> query(q);
    for (auto &x : query) cin >> x;

    for (auto &x : query) {
        int l = -1, r = n-1;
        while (r-l > 1) {
            int m = (l+r)/2;
            if (x>pref[m+1]) l=m;
            else r=m;
        }
        cout << len[r] << "\n";
    }

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