제출 #1350085

#제출 시각아이디문제언어결과실행 시간메모리
1350085guardianecIntercastellar (JOI22_ho_t1)C++20
100 / 100
44 ms6984 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({k, m});
    }

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

    ll curr = 0;
    for (int i=0; i<n; i++) {
        curr+=res[i].first;
        res[i] = {curr-1, res[i].second};
    }

    ll q;
    cin >> q;

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

        auto it = upper_bound(res.begin(), res.end(), make_pair(x, 0LL));
        cout << (it->second) << "\n";
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...