제출 #1332478

#제출 시각아이디문제언어결과실행 시간메모리
1332478BolatuluIntercastellar (JOI22_ho_t1)C++20
100 / 100
50 ms7008 KiB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;

#define all(x) (x).begin(), (x).end()
#define md ((tl + tr) >> 1)
#define TL v + v, tl, md
#define TR v + v + 1, md + 1, tr
#define F first
#define S second
#define pii pair<int, int>
#define int ll

const int maxn = 3e5 + 7;
const ll inf = 1e18 + 7;
const double PI = atan2(0.0, -1.0);

int n, a[maxn], q, x[maxn], ps[maxn];

void solve() {
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    cin >> q;
    for (int i = 1; i <= q; i++)
        cin >> x[i];

    for (int i = 1; i <= n; i++) {
        int c = 1;
        while (!(a[i] & 1))
            a[i] >>= 1, c <<= 1;
        ps[i] = ps[i - 1] + c;
    }

    for (int i = 1; i <= q; i++) {
        int l = 0, r = n;
        while (l + 1 < r) {
            int mid = ((l + r) >> 1);
            if (ps[mid] >= x[i])
                r = mid;
            else
                l = mid;
        }
        cout << a[r] << '\n';
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int test = 1;
    // cin >> test;
    while (test--) {
        solve();
        // cout << '\n';
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...