Submission #1349095

#TimeUsernameProblemLanguageResultExecution timeMemory
1349095Born_To_LaughIntercastellar (JOI22_ho_t1)C++17
100 / 100
37 ms5444 KiB
// Born_To_Laugh - Hughie Do
#include <bits/stdc++.h>
#define alle(AC) AC.begin(), AC.end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
[[maybe_unused]] const int MOD = 998244353, INF = 1e9 + 7;
const int maxn = 2e5 + 10;
int n, q;
ll pref[maxn], val[maxn];
void solve(){
    cin >> n;
    for(int i=1; i<=n; ++i){
        int x;cin >> x;
        int cnt = 0;
        while(!(x & 1)){
            cnt++;
            x = x >> 1;
        }
        pref[i] = (1 << cnt) + pref[i - 1];
        val[i] = x;
    }
    cin >> q;
    while(q--){
        ll x;cin >> x;
        int lo = 1, hi = n, res = n;
        while(hi >= lo){
            int mid = (lo + hi) >> 1;
            if(pref[mid] >= x){
                res = mid;
                hi = mid - 1;
            }
            else lo = mid + 1;
        }
        cout << val[res] << '\n';
    }
}
signed main(){
    // freopen("inp.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...