#include <bits/stdc++.h>
using namespace std;
int64_t suma[200001];
int sir[200001];
int main ()
{
    ios :: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int lungime;
    cin >> lungime;
    for (int indice = 1 ; indice <= lungime ; indice++)
    {
        cin >> sir[indice];
        suma[indice] = 1;
        while (!(sir[indice] & 1))
        {
            sir[indice] >>= 1;
            suma[indice] <<= 1;
        }
        suma[indice] += suma[indice - 1];
    }
    int numar_intrebari;
    cin >> numar_intrebari;
    while (numar_intrebari--)
    {
        int64_t pozitie;
        cin >> pozitie;
        int indice = 0;
        for (int putere = (1 << 17) ; putere ; putere >>= 1) {
            if ((indice | putere) < lungime && suma[indice | putere] < pozitie)
                { indice |= putere; }
        }
        cout << sir[indice + 1] << '\n';
    }
    
    return 0;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |