Submission #936128

#TimeUsernameProblemLanguageResultExecution timeMemory
936128weakweakweakIntercastellar (JOI22_ho_t1)C++14
100 / 100
68 ms12628 KiB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
ll a[310000] = {0}, cnt[310000] = {0}, pre[310000] = {0};

int main () {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, q, x;
    vector <int> v;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        cnt[i] = 1;
        while (a[i] % 2 == 0) {
            a[i] >>= 1;
            cnt[i] <<= 1;
        }
    }
    
    for (int i = 1; i <= n; i++) pre[i] = pre[i - 1] + cnt[i];
    ll y;
    cin >> q;
    while (q--) {
        cin >> y;
        int ii = lower_bound(pre + 1, pre + 1 + n, y) - pre;
        cout << a[ii] << '\n'; 
    }
}

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:9:15: warning: unused variable 'x' [-Wunused-variable]
    9 |     int n, q, x;
      |               ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...