제출 #593555

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

using namespace std;

using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    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 cnt = 1;
        while (a[i] % 2 == 0) {
            a[i] /= 2;
            cnt *= 2;
        }
        b[i] = {cnt, a[i]};
    }
    int q;
    cin >> q;
    ll sum = 0;
    int pnt = -1;
    while (q--) {
        ll x;
        cin >> x;
        while (pnt < n && sum + b[pnt + 1].first < x) {
            sum += b[++pnt].first;
        }
        cout << b[pnt + 1].second << '\n';
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...