제출 #686753

#제출 시각아이디문제언어결과실행 시간메모리
686753yaufungIntercastellar (JOI22_ho_t1)C++17
100 / 100
74 ms9960 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int q;
    cin >> q;
    vector<long long> b(q);
    for (int i = 0; i < q; i++) {
        cin >> b[i];
    }
    vector<int> num(n);
    vector<int> ct(n);
    for (int i = 0; i < n; i++) {
        int c = 1;
        int x = a[i];
        while (x % 2 == 0) {
            c *= 2;
            x /= 2;
        }
        num[i] = x;
        ct[i] = c;
    }
    int p = 0;
    long long sum = 0;
    for (int i = 0; i < q; i++) {
        while (sum + ct[p] < b[i]) {
            sum += ct[p];
            p++;
        }
        cout << num[p] << "\n";
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...