Submission #838416

# Submission time Handle Problem Language Result Execution time Memory
838416 2023-08-26T20:05:33 Z makrav Intercastellar (JOI22_ho_t1) C++14
100 / 100
76 ms 12324 KB
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vei;
typedef vector<vei> vevei;

#define all(a) (a).begin(), (a).end()
#define sz(a) (int) a.size()
#define con cout << "NO\n"
#define coe cout << "YES\n";
#define str string
#define pb push_back
#define ff first
#define sc second
#define pii pair<int, int>
#define mxe max_element
#define mne min_element
#define stf shrink_to_fit
#define f(i, l, r) for (int i = (l); i < (r); i++)
#define double ld
#define int ll

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int n; cin >> n;
    vector<int> a(n);
    f(i, 0, n) cin >> a[i];
    vector<int> cnt(n, 0), val(n);
    f(i, 0, n) {
        int c = 1, v = a[i];
        while (v % 2 == 0) {
            c *= 2;
            v /= 2;
        }
        cnt[i] = c; val[i] = v;
    }
    vector<int> pref(n + 1, 0);
    f(i, 1, n + 1) pref[i] = pref[i - 1] + cnt[i - 1];
    int q; cin >> q;
    while (q--) {
        int x; cin >> x;
        int L = 0, R = n;
        while (R - L > 1) {
            int M = (L + R) / 2;
            if (pref[M] >= x) R = M;
            else L = M;
        }
        cout << val[L] << '\n';
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 19 ms 6356 KB Output is correct
4 Correct 30 ms 2092 KB Output is correct
5 Correct 49 ms 6888 KB Output is correct
6 Correct 28 ms 5708 KB Output is correct
7 Correct 49 ms 6924 KB Output is correct
8 Correct 50 ms 6888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 19 ms 6356 KB Output is correct
4 Correct 30 ms 2092 KB Output is correct
5 Correct 49 ms 6888 KB Output is correct
6 Correct 28 ms 5708 KB Output is correct
7 Correct 49 ms 6924 KB Output is correct
8 Correct 50 ms 6888 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 26 ms 3540 KB Output is correct
24 Correct 30 ms 7440 KB Output is correct
25 Correct 66 ms 11856 KB Output is correct
26 Correct 41 ms 7500 KB Output is correct
27 Correct 36 ms 7756 KB Output is correct
28 Correct 71 ms 12324 KB Output is correct
29 Correct 70 ms 11852 KB Output is correct
30 Correct 37 ms 4072 KB Output is correct
31 Correct 76 ms 12268 KB Output is correct