Submission #1179912

#TimeUsernameProblemLanguageResultExecution timeMemory
1179912anteknneIntercastellar (JOI22_ho_t1)C++20
100 / 100
57 ms6980 KiB
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define st first
#define nd second
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define debug false

const int MAXN = 200 * 1000 + 1;
ll a[MAXN];
ll ile[MAXN];
ll spref[MAXN];

int main () {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i ++) {
        cin >> a[i];
    }

    for (int i = 1; i <= n; i ++) {
        ll j = 1;
        while (a[i] % (j * 2LL) == 0LL) {
            j *= 2LL;
        }
        ile[i]= j;
    }

    for (int i = 1; i <= n; i ++) {
        spref[i] = spref[i - 1] + ile[i];
    }

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

        int p = 0, k = n, wyn = 0;
        while (p <= k) {
            int sr = (p + k)/ 2;
            if (spref[sr] < x) {
                wyn = sr;
                p = sr + 1;
            } else {
                k = sr - 1;
            }
        }
        wyn ++;
        cout << a[wyn]/ ile[wyn] << "\n";

    }

    return 0;
}


#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...