제출 #862224

#제출 시각아이디문제언어결과실행 시간메모리
862224arbuzickIntercastellar (JOI22_ho_t1)C++17
100 / 100
91 ms10068 KiB
#include <bits/stdc++.h>

using namespace std;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<pair<int, int>> b(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        int pw = 0;
        while (a[i] % (1 << (pw + 1)) == 0) {
            pw++;
        }
        b[i] = {1 << pw, a[i] / (1 << pw)};
    }
    vector<long long> pr_cnt(n + 1);
    for (int i = 0; i < n; ++i) {
        pr_cnt[i + 1] = pr_cnt[i] + b[i].first;
    }
    int q;
    cin >> q;
    while (q--) {
        long long x;
        cin >> x;
        x--;
        int pos = upper_bound(pr_cnt.begin(), pr_cnt.end(), x) - pr_cnt.begin() - 1;
        cout << b[pos].second << '\n';
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...