Submission #703573

# Submission time Handle Problem Language Result Execution time Memory
703573 2023-02-27T17:16:03 Z Jeff12345121 Intercastellar (JOI22_ho_t1) C++14
100 / 100
203 ms 14656 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;

#ifdef LOCAL
ifstream in("in.in");
ofstream out("out.out");
#else
#define in cin
#define out cout
#endif

const int nmax = 200005;
int n,a[nmax],q,nr[nmax],val[nmax];

pair<int,int> get_nr(int x) {
    int nr = 1;
    while(x%2 == 0) {
        nr = nr * 2;
        x /= 2;
    }
    return {nr,x};
}
pair<int,int> qs[nmax];
int sol[nmax];
int32_t main() {
    in >> n;
    for (int i = 1; i <= n; i++) {
        in >> a[i];
    }

    for (int i = 1; i <= n; i++) {
        auto v = get_nr(a[i]);
        nr[i] = v.first;
        val[i] = v.second;
        nr[i] += nr[i - 1];
    }

    in >> q;

    for (int i = 1; i <= q; i++) {
        int x;
        in >> x;
        qs[i] = {x, i};
    }
    sort(qs + 1, qs + 1 + q);

    int p = 1;
    for (int i = 1; i <= q; i++) {
        while(nr[p] < qs[i].first) {
            p++;
        }
        sol[qs[i].second] = val[p];
    }

    for (int i = 1; i <= q; i++) {
        out << sol[i] << "\n";
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 40 ms 5676 KB Output is correct
4 Correct 60 ms 5252 KB Output is correct
5 Correct 101 ms 10016 KB Output is correct
6 Correct 57 ms 7628 KB Output is correct
7 Correct 99 ms 11696 KB Output is correct
8 Correct 99 ms 11820 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 340 KB Output is correct
5 Correct 1 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 340 KB Output is correct
9 Correct 1 ms 340 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 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 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 40 ms 5676 KB Output is correct
4 Correct 60 ms 5252 KB Output is correct
5 Correct 101 ms 10016 KB Output is correct
6 Correct 57 ms 7628 KB Output is correct
7 Correct 99 ms 11696 KB Output is correct
8 Correct 99 ms 11820 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 340 KB Output is correct
13 Correct 1 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 340 KB Output is correct
17 Correct 1 ms 340 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 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 59 ms 6104 KB Output is correct
24 Correct 89 ms 8240 KB Output is correct
25 Correct 163 ms 14656 KB Output is correct
26 Correct 109 ms 9016 KB Output is correct
27 Correct 102 ms 8696 KB Output is correct
28 Correct 191 ms 13864 KB Output is correct
29 Correct 203 ms 13028 KB Output is correct
30 Correct 96 ms 7500 KB Output is correct
31 Correct 194 ms 13640 KB Output is correct