Submission #884457

# Submission time Handle Problem Language Result Execution time Memory
884457 2023-12-07T11:51:04 Z EJIC_B_KEDAX Intercastellar (JOI22_ho_t1) C++14
25 / 100
59 ms 4944 KB
#ifdef LOCAL
    //#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#include <random>

#ifndef LOCAL
    //#pragma GCC optimize("O3")
    //#pragma GCC optimize("Ofast")
    //#pragma GCC optimize("unroll-loops")
    #pragma GCC target("avx,avx2,bmi,bmi2,popcnt,lzcnt")
#endif
using namespace std;
using ll = long long;
using ld = long double;
#define x first
#define y second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

mt19937_64 mt(418);

void solve();
void init();

int32_t main() {
#ifndef LOCAL
    cin.tie(nullptr)->sync_with_stdio(false);
#else
    freopen("input.txt", "r", stdin);
#endif
    // srand(time(0));
    init();
    cout << fixed << setprecision(20);
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}

void init() {}

void solve() {
    int n;
    cin >> n;
    vector<int> a(n), b(n, 1), pref(n + 1, 0);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        while (~a[i] & 1) {
            b[i] <<= 1;
            a[i] >>= 1;
        }
    }
    for (int i = 0; i < n; i++) {
        pref[i + 1] = pref[i] + b[i];
    }
    int q;
    cin >> q;
    while (q--) {
        ll x;
        cin >> x;
        int l = -1, r = n + 1;
        while (r - l > 1) {
            int m = (r + l) / 2;
            if (pref[m] >= x) {
                r = m;
            } else {
                l = m;
            }
        }
        cout << a[l] << '\n';
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 18 ms 3228 KB Output is correct
4 Correct 31 ms 2304 KB Output is correct
5 Correct 51 ms 4892 KB Output is correct
6 Correct 31 ms 3412 KB Output is correct
7 Correct 56 ms 4912 KB Output is correct
8 Correct 59 ms 4944 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Incorrect 0 ms 348 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 18 ms 3228 KB Output is correct
4 Correct 31 ms 2304 KB Output is correct
5 Correct 51 ms 4892 KB Output is correct
6 Correct 31 ms 3412 KB Output is correct
7 Correct 56 ms 4912 KB Output is correct
8 Correct 59 ms 4944 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Incorrect 0 ms 348 KB Output isn't correct
18 Halted 0 ms 0 KB -