Submission #1350082

#TimeUsernameProblemLanguageResultExecution timeMemory
1350082guardianecIntercastellar (JOI22_ho_t1)C++20
35 / 100
2093 ms6220 KiB
#include <bits/stdc++.h>
#define ll long long
using namespace std;

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

    ll n;
    cin >> n;
    vector<ll> a(n);
    for (int i=0; i<n; i++) {
        cin >> a[i];
    }

    vector<pair<ll,ll>> res;

    for (int i=n-1; i>=0; i--) {
        ll m = a[i];
        ll k = 1;
        while(m%2==0) {
            m/=2;
            k*=2;
        }
        res.push_back({m, k});
    }

    reverse(res.begin(), res.end());

    ll q;
    cin >> q;

    while(q--) {
        ll x;
        cin >> x; x--;

        ll curr = 0;
        for (int i=0; i<n; i++) {
            if (x<curr+res[i].second) {
                cout << res[i].first << "\n";
                break;
            } else curr+=res[i].second;
        }
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...