제출 #879901

#제출 시각아이디문제언어결과실행 시간메모리
879901frostray8653Intercastellar (JOI22_ho_t1)C++17
100 / 100
62 ms10324 KiB
#include <bits/stdc++.h>
#define int long long
#define IO ios::sync_with_stdio(0), cin.tie(0);
#define FOR(i, a, b) for (int i = a; i <= b; i++)
using namespace std;
using pii = pair<int, int>;
void dbg() {;}
template<class T, class ...U>
void dbg(T a, U ...b) { cout << a << " "; dbg(b...); }
void ent() { cout << "\n"; }
const int INF = 1e16;
const int N = 200005;

int a[N], b[N];
int num[N], pre[N];

signed main() {
    IO;
    
    int n, x;
    cin >> n;
    FOR(i, 1, n) {
        cin >> x;
        int cnt = 1;
        while (x % 2 == 0) {
            x /= 2;
            cnt *= 2;
        }
        num[i] = x;
        pre[i] = pre[i - 1] + cnt;
    }
    int q;
    cin >> q;
    while (q--) {
        cin >> x;
        int id = lower_bound(pre + 1, pre + n + 1, x) - pre;
        cout << num[id] << "\n";
    }

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