Submission #612295

# Submission time Handle Problem Language Result Execution time Memory
612295 2022-07-29T12:44:40 Z boris_mihov Intercastellar (JOI22_ho_t1) C++14
100 / 100
100 ms 8344 KB
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

typedef long long llong;
const int MAXN = 200000 + 10;

int a[MAXN], n, q;
llong prefix[MAXN];

void solve()
{
    for (int i = 1 ; i <= n ; ++i)
    {
        prefix[i] = prefix[i-1] + (a[i] & -a[i]);
    }

    int ptr = 1;
    llong x;
    
    for (int i = 1 ; i <= q ; ++i)
    {
        std::cin >> x;
        while (prefix[ptr] <= x-1) ++ptr;
        std::cout << a[ptr] / (a[ptr] & -(a[ptr])) << '\n';
    }
}

void read()
{
    std::cin >> n;
    for (int i = 1 ; i <= n ; ++i)
    {
        std::cin >> a[i];
    }

    std::cin >> q;
}

void fastIO()
{
    std::ios_base :: sync_with_stdio(0);
    std::cout.tie(nullptr);
    std::cin.tie(nullptr);
}

int main()
{
    fastIO();
    read();
    solve();

    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 17 ms 2644 KB Output is correct
4 Correct 29 ms 1080 KB Output is correct
5 Correct 46 ms 2996 KB Output is correct
6 Correct 29 ms 2480 KB Output is correct
7 Correct 42 ms 3020 KB Output is correct
8 Correct 50 ms 3084 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 1 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 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 0 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 360 KB Output is correct
13 Correct 1 ms 336 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 17 ms 2644 KB Output is correct
4 Correct 29 ms 1080 KB Output is correct
5 Correct 46 ms 2996 KB Output is correct
6 Correct 29 ms 2480 KB Output is correct
7 Correct 42 ms 3020 KB Output is correct
8 Correct 50 ms 3084 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 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 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 256 KB Output is correct
17 Correct 0 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 360 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 24 ms 2876 KB Output is correct
24 Correct 37 ms 4692 KB Output is correct
25 Correct 78 ms 8004 KB Output is correct
26 Correct 45 ms 5040 KB Output is correct
27 Correct 37 ms 5028 KB Output is correct
28 Correct 78 ms 8344 KB Output is correct
29 Correct 70 ms 7840 KB Output is correct
30 Correct 42 ms 3640 KB Output is correct
31 Correct 100 ms 8304 KB Output is correct