Submission #527484

#TimeUsernameProblemLanguageResultExecution timeMemory
527484voventaIntercastellar (JOI22_ho_t1)C++17
100 / 100
76 ms10512 KiB
#include <bits/stdc++.h>
#define x first
#define y second
#define sz(a) (int)a.size()
#define pb push_back
#define int long long

using namespace std;
typedef long long ll;

const int K = 5000;

void solve();

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    //cin >> t;
    while (t--)
        solve();
    return 0;
}

pair <int, int> a[200010];
int pref[200010];

int get(int x) {
    int t = 1;
    while (x % 2 == 0) {
        t *= 2;
        x /= 2;
    }
    return t;
}

void solve() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i].x;
        a[i].y = get(a[i].x);
    }
    for (int i = 1; i <= n; ++i)
        pref[i] = pref[i - 1] + a[i - 1].y;
    int q, x;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        cin >> x;
        int t = lower_bound(pref, pref + n + 1, x) - pref - 1;
        cout << a[t].x / a[t].y << '\n';
    }

}
//923953850098595069
//890909762780980010

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