Submission #1098739

# Submission time Handle Problem Language Result Execution time Memory
1098739 2024-10-09T19:53:33 Z anhthi Brunhilda’s Birthday (BOI13_brunhilda) C++14
100 / 100
141 ms 80796 KB
#include <bits/stdc++.h>
 
using namespace std;
 
#define fi first
#define se second
#define ll long long
#define mp(x, y) make_pair(x, y)
#define sz(v) ((int) (v).size())
#define all(v) (v).begin(), (v).end()
#define MASK(i) (1LL << (i))
#define BIT(x, y) (((x) >> (y)) & 1)
#define pb push_back
#define heap priority_queue
#define max_rng *max_element
#define min_rng *min_element
#define rep(i, n) for(int i = 1, _n = (n); i <= _n; ++i)
#define forn(i, a, b) for(int i = (a), _b = (b); i <= _b; ++i)
#define ford(i, a, b) for(int i = (a), _b = (b); i >= _b; --i)

 
template <class X, class Y>
    inline bool maximize(X &x, Y y) {
        return (x < y ? x = y, true : false);
    }
 
template <class X, class Y>
    inline bool minimize(X &x, Y y) {
        return (x > y ? x = y, true : false);
    }
 
template <class X>
    inline void compress(vector<X> &a) {
        sort(all(a));
        a.resize(unique(all(a)) - a.begin());
    }
 
int ctz(ll x) { return __builtin_ctzll(x); }
int lg(ll x) { return 63 - __builtin_clzll(x); }
int popcnt(ll x) { return __builtin_popcount(x); }
 
mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
ll rand(ll l, ll r) {
    return l + abs((ll) rng()) % (r - l + 1);
}
 
const ll oo = (ll) 1e18 + 5;
const int inf = (ll) 1e9 + 7, mod = (ll) 1e9 + 7;
 
const int N = 1e5 + 5, M = 1e7 + 5;
 
void add(int &x, int y) { x += y; if (x >= mod) x -= mod; }
void sub(int &x, int y) { x -= y; if (x < 0) x += mod; }

int n, m;
int a[N];

int trans[M + 5], f[M + 5];

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

    cin >> n >> m;
    rep(i, n) cin >> a[i];
    rep(i, n) {
        for(int j = a[i] - 1; j <= M; j += a[i])
            trans[j] = a[i] - 1;
        maximize(trans[M], M % a[i]); 
    }
    ford(i, M, 1) {
        maximize(trans[i], trans[i + 1] - 1); 
    }
    forn(i, 1, M) {
        f[i] = inf;
        minimize(f[i], f[i - trans[i]] + 1);
    }
    int s;
    while (m--) {
        cin >> s;
        if (f[s] == inf)
            cout << "oo\n";
        else cout << f[s] << '\n';
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 47 ms 78676 KB Output is correct
2 Correct 53 ms 78516 KB Output is correct
3 Correct 52 ms 78520 KB Output is correct
4 Correct 44 ms 78768 KB Output is correct
5 Correct 51 ms 78676 KB Output is correct
6 Correct 47 ms 78672 KB Output is correct
7 Correct 54 ms 78676 KB Output is correct
8 Correct 54 ms 78524 KB Output is correct
9 Correct 61 ms 78672 KB Output is correct
10 Correct 64 ms 78672 KB Output is correct
11 Correct 65 ms 78676 KB Output is correct
12 Correct 45 ms 78676 KB Output is correct
13 Correct 82 ms 78532 KB Output is correct
14 Correct 83 ms 78676 KB Output is correct
15 Correct 55 ms 78516 KB Output is correct
16 Correct 53 ms 78672 KB Output is correct
17 Correct 53 ms 78928 KB Output is correct
18 Correct 44 ms 78684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 78672 KB Output is correct
2 Correct 54 ms 79644 KB Output is correct
3 Correct 97 ms 79440 KB Output is correct
4 Correct 53 ms 78672 KB Output is correct
5 Correct 91 ms 79056 KB Output is correct
6 Correct 58 ms 78672 KB Output is correct
7 Correct 48 ms 78676 KB Output is correct
8 Correct 57 ms 78676 KB Output is correct
9 Correct 96 ms 79444 KB Output is correct
10 Correct 120 ms 79252 KB Output is correct
11 Correct 112 ms 79088 KB Output is correct
12 Correct 75 ms 78536 KB Output is correct
13 Correct 54 ms 78552 KB Output is correct
14 Correct 70 ms 78672 KB Output is correct
15 Correct 95 ms 78948 KB Output is correct
16 Correct 55 ms 79696 KB Output is correct
17 Correct 90 ms 78676 KB Output is correct
18 Correct 95 ms 79700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 119 ms 79444 KB Output is correct
2 Correct 128 ms 79436 KB Output is correct
3 Correct 119 ms 79700 KB Output is correct
4 Correct 96 ms 79696 KB Output is correct
5 Correct 78 ms 80724 KB Output is correct
6 Correct 113 ms 79696 KB Output is correct
7 Correct 94 ms 80296 KB Output is correct
8 Correct 99 ms 79440 KB Output is correct
9 Correct 91 ms 79444 KB Output is correct
10 Correct 71 ms 78892 KB Output is correct
11 Correct 69 ms 78884 KB Output is correct
12 Correct 81 ms 78932 KB Output is correct
13 Correct 105 ms 79956 KB Output is correct
14 Correct 78 ms 80064 KB Output is correct
15 Correct 87 ms 78892 KB Output is correct
16 Correct 96 ms 78932 KB Output is correct
17 Correct 85 ms 79080 KB Output is correct
18 Correct 104 ms 79460 KB Output is correct
19 Correct 54 ms 78928 KB Output is correct
20 Correct 101 ms 79700 KB Output is correct
21 Correct 79 ms 79876 KB Output is correct
22 Correct 118 ms 80796 KB Output is correct
23 Correct 82 ms 79956 KB Output is correct
24 Correct 70 ms 79700 KB Output is correct
25 Correct 95 ms 79780 KB Output is correct
26 Correct 96 ms 79660 KB Output is correct
27 Correct 136 ms 80284 KB Output is correct
28 Correct 67 ms 79700 KB Output is correct
29 Correct 118 ms 80724 KB Output is correct
30 Correct 111 ms 80436 KB Output is correct
31 Correct 76 ms 79448 KB Output is correct
32 Correct 83 ms 79696 KB Output is correct
33 Correct 71 ms 79560 KB Output is correct
34 Correct 97 ms 80208 KB Output is correct
35 Correct 66 ms 79700 KB Output is correct
36 Correct 141 ms 80504 KB Output is correct
37 Correct 77 ms 80632 KB Output is correct
38 Correct 109 ms 79540 KB Output is correct
39 Correct 76 ms 79580 KB Output is correct
40 Correct 90 ms 79548 KB Output is correct
41 Correct 80 ms 80296 KB Output is correct
42 Correct 96 ms 79696 KB Output is correct