Submission #1166031

#TimeUsernameProblemLanguageResultExecution timeMemory
1166031tvgkIntercastellar (JOI22_ho_t1)C++20
100 / 100
40 ms5444 KiB
#include<bits/stdc++.h>
using namespace std;
#define task "a"
#define se second
#define fi first
#define ll long long
#define ii pair<ll, ll>
const long mxN = 2e5 + 7;

int n;
ll cnt[mxN], a[mxN];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen(task".INP", "r", stdin);
    //freopen(task".OUT", "w", stdout);

    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        cnt[i] = 1;
        while (a[i] % 2 == 0)
        {
            cnt[i] *= 2;
            a[i] /= 2;
        }
    }

    int q;
    cin >> q;
    ll cur = 0;
    int ctr = 0;
    for (int i = 1; i <= q; i++)
    {
        ll tmp;
        cin >> tmp;
        while (tmp > cur)
        {
            ctr++;
            cur += cnt[ctr];
        }
        cout << a[ctr] << '\n';
    }
}

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