Submission #1354602

#TimeUsernameProblemLanguageResultExecution timeMemory
1354602SulAIntercastellar (JOI22_ho_t1)C++20
25 / 100
22 ms4160 KiB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define popcount __builtin_popcount
#define all(a) (a).begin(), (a).end()
using namespace std;
using namespace chrono;
using namespace __gnu_pbds;
template<typename T> using ordered_set = tree<T,null_type,less_equal<>,rb_tree_tag,tree_order_statistics_node_update>;

void solve(int n, int *A, long long *pref) {
    pref[0] = 0;
    for (int i = 1; i < n; i++) {
        pref[i] = pref[i-1] + max(0, A[i-1] - A[i] + 1);
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n; cin >> n;
    vector<long long> pos{0}, val{0};
    for (int i = 0, x; i < n; i++) {
        cin >> x;
        int cnt = 1;
        while (x % 2 == 0) cnt *= 2, x /= 2;
        pos.push_back(pos.back() + cnt);
        val.push_back(x);
    }
    int p = 0, q; cin >> q;
    while (q--) {
        int x; cin >> x;
        while (x > pos[p]) p++;
        cout << val[p] << "\n";
    }
}
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...