제출 #1340931

#제출 시각아이디문제언어결과실행 시간메모리
1340931jayssIntercastellar (JOI22_ho_t1)C++20
100 / 100
52 ms5316 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long

const int N = 2e5 + 5;

int A[N], B[N];
int32_t main() {
    ios_base::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);

    int n; cin >> n;
    for (int i = 0;i < n;i++) {
        int x; cin >> x;
        int amt = 1;
        while (!(x & 1)) {
            x >>= 1;
            amt <<= 1;
        }
        if (i == 0) A[i] = amt;
        else A[i] = A[i - 1] + amt;
        B[i] = x;
    }
    int q; cin >> q;
    while (q--) {
        int x; cin >> x;
        auto it = lower_bound(A, A + n, x);
        int idx = it - A;
        cout << B[idx] << '\n';
    }

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...