Submission #715273

# Submission time Handle Problem Language Result Execution time Memory
715273 2023-03-26T10:19:37 Z alextodoran Intercastellar (JOI22_ho_t1) C++17
100 / 100
84 ms 9172 KB
/**
 ____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|

**/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N_MAX = 200000;
const int Q_MAX = 200000;

int N, Q;
ll A[N_MAX + 2];
ll pref[N_MAX + 2];

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> N;
    for (int i = 1; i <= N; i++) {
        cin >> A[i];
        pref[i] = 1;
        while (A[i] % 2 == 0) {
            A[i] /= 2;
            pref[i] *= 2;
        }
        pref[i] += pref[i - 1];
    }
    cin >> Q;
    while (Q--) {
        ll X;
        cin >> X;
        int l = 1, r = N;
        while (l < r) {
            int mid = (l + r) / 2;
            if (X <= pref[mid]) {
                r = mid;
            } else {
                l = mid + 1;
            }
        }
        cout << A[l] << "\n";
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 328 KB Output is correct
3 Correct 24 ms 4092 KB Output is correct
4 Correct 31 ms 2260 KB Output is correct
5 Correct 51 ms 5492 KB Output is correct
6 Correct 46 ms 3992 KB Output is correct
7 Correct 65 ms 5452 KB Output is correct
8 Correct 54 ms 5608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 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 328 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 376 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 1 ms 212 KB Output is correct
2 Correct 0 ms 328 KB Output is correct
3 Correct 24 ms 4092 KB Output is correct
4 Correct 31 ms 2260 KB Output is correct
5 Correct 51 ms 5492 KB Output is correct
6 Correct 46 ms 3992 KB Output is correct
7 Correct 65 ms 5452 KB Output is correct
8 Correct 54 ms 5608 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 340 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 328 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 376 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 28 ms 3048 KB Output is correct
24 Correct 38 ms 5140 KB Output is correct
25 Correct 74 ms 8700 KB Output is correct
26 Correct 46 ms 5580 KB Output is correct
27 Correct 42 ms 5580 KB Output is correct
28 Correct 78 ms 9168 KB Output is correct
29 Correct 84 ms 8640 KB Output is correct
30 Correct 43 ms 3676 KB Output is correct
31 Correct 83 ms 9172 KB Output is correct