제출 #1249335

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

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define int long long
#define yes() cout << "YES\n"
#define no() cout << "NO\n"

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;

const int inf = 1e18;
const int mod = 1e9 + 7;
const int maxn = 1e7 + 5e6;
const int mod1 = 998244353;
const int mod2 = 1e18 + 1;
const int mod3 = 1e9 + 9;
const int mod4 = 333333333;
const int mod5 = 200000;
const int mod6 = 10007;
const int k = 300;
const int w = 1e5;
const ld EPS = 1e-8;

int LOG = 30;

void solve() {
    int n;
    cin >> n;

    vector<int> a(n);
    for (int& i : a) cin >> i;

    int q;
    cin >> q;

    int i = -1;
    int cnt = 0;
    int prime = -1;

    while (q--) {
        int x;
        cin >> x;

        // x--;
        while (cnt < x) {
            i++;
            int tmp = 1;
            while (a[i] % 2 == 0) {
                tmp *= 2;
                a[i] /= 2;
            }
            cnt += tmp;
            prime = a[i];
        }

        cout << prime << "\n";
    }
}

signed main() {
    // cout.precision(16);

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
    // cin >> t;

    while (t--) {
        solve();
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...