Submission #1026802

# Submission time Handle Problem Language Result Execution time Memory
1026802 2024-07-18T11:29:56 Z VMaksimoski008 Brunhilda’s Birthday (BOI13_brunhilda) C++17
20 / 100
1000 ms 40020 KB
#include <bits/stdc++.h>

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
//#define int long long

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int mod = 1e9 + 7;
const int LOG = 20;
const int maxn = 1e7 + 5;

vector<int> dp(maxn, 1e9);

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

    int n, q;
    cin >> n >> q;

    vector<int> p(n);
    for(int &x : p) cin >> x;

    dp[0] = 0;
    for(int i=1; i<=10000; i++) {
        for(int &x : p) {
            if(i % x == 0) continue;
            dp[i] = min(dp[i], dp[(i/x)*x] + 1);
        }
    }

    while(q--) {
        int x;
        cin >> x;
        if(dp[x] < 1e9) cout << dp[x] << '\n';
        else cout << "oo\n";
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 8 ms 39512 KB Output is correct
2 Correct 11 ms 39516 KB Output is correct
3 Correct 8 ms 39516 KB Output is correct
4 Correct 10 ms 39616 KB Output is correct
5 Correct 8 ms 39516 KB Output is correct
6 Correct 7 ms 39568 KB Output is correct
7 Correct 8 ms 39516 KB Output is correct
8 Correct 8 ms 39516 KB Output is correct
9 Correct 7 ms 39496 KB Output is correct
10 Correct 7 ms 39516 KB Output is correct
11 Correct 8 ms 39516 KB Output is correct
12 Correct 9 ms 39516 KB Output is correct
13 Correct 31 ms 39368 KB Output is correct
14 Correct 31 ms 39608 KB Output is correct
15 Correct 8 ms 39516 KB Output is correct
16 Correct 8 ms 39516 KB Output is correct
17 Correct 9 ms 39568 KB Output is correct
18 Correct 10 ms 39368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 278 ms 39516 KB Output isn't correct
2 Execution timed out 1043 ms 39768 KB Time limit exceeded
3 Execution timed out 1028 ms 39772 KB Time limit exceeded
4 Incorrect 79 ms 39512 KB Output isn't correct
5 Execution timed out 1029 ms 39768 KB Time limit exceeded
6 Incorrect 35 ms 39512 KB Output isn't correct
7 Incorrect 281 ms 39516 KB Output isn't correct
8 Incorrect 30 ms 39512 KB Output isn't correct
9 Execution timed out 1033 ms 39772 KB Time limit exceeded
10 Execution timed out 1022 ms 39768 KB Time limit exceeded
11 Incorrect 919 ms 39768 KB Output isn't correct
12 Incorrect 55 ms 39516 KB Output isn't correct
13 Incorrect 74 ms 39516 KB Output isn't correct
14 Incorrect 79 ms 39560 KB Output isn't correct
15 Incorrect 967 ms 39772 KB Output isn't correct
16 Execution timed out 1037 ms 39768 KB Time limit exceeded
17 Incorrect 76 ms 39512 KB Output isn't correct
18 Execution timed out 1067 ms 39768 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1037 ms 39768 KB Time limit exceeded
2 Execution timed out 1031 ms 39772 KB Time limit exceeded
3 Execution timed out 1087 ms 39768 KB Time limit exceeded
4 Incorrect 101 ms 39612 KB Output isn't correct
5 Execution timed out 1044 ms 39768 KB Time limit exceeded
6 Incorrect 209 ms 39868 KB Output isn't correct
7 Execution timed out 1080 ms 39868 KB Time limit exceeded
8 Execution timed out 1070 ms 39748 KB Time limit exceeded
9 Execution timed out 1072 ms 39772 KB Time limit exceeded
10 Incorrect 142 ms 39516 KB Output isn't correct
11 Incorrect 112 ms 39652 KB Output isn't correct
12 Incorrect 145 ms 39620 KB Output isn't correct
13 Incorrect 680 ms 40020 KB Output isn't correct
14 Incorrect 19 ms 39772 KB Output isn't correct
15 Incorrect 137 ms 39516 KB Output isn't correct
16 Incorrect 168 ms 39628 KB Output isn't correct
17 Incorrect 985 ms 39772 KB Output isn't correct
18 Execution timed out 1050 ms 39768 KB Time limit exceeded
19 Incorrect 127 ms 39604 KB Output isn't correct
20 Execution timed out 1047 ms 39768 KB Time limit exceeded
21 Incorrect 15 ms 39772 KB Output isn't correct
22 Execution timed out 1099 ms 39772 KB Time limit exceeded
23 Incorrect 606 ms 39968 KB Output isn't correct
24 Incorrect 39 ms 39760 KB Output isn't correct
25 Incorrect 85 ms 39760 KB Output isn't correct
26 Incorrect 94 ms 39604 KB Output isn't correct
27 Execution timed out 1035 ms 39768 KB Time limit exceeded
28 Incorrect 37 ms 39760 KB Output isn't correct
29 Execution timed out 1080 ms 39864 KB Time limit exceeded
30 Execution timed out 1054 ms 39768 KB Time limit exceeded
31 Incorrect 108 ms 39852 KB Output isn't correct
32 Incorrect 73 ms 39760 KB Output isn't correct
33 Incorrect 44 ms 39712 KB Output isn't correct
34 Execution timed out 1077 ms 39772 KB Time limit exceeded
35 Incorrect 52 ms 39764 KB Output isn't correct
36 Execution timed out 1077 ms 39772 KB Time limit exceeded
37 Execution timed out 1038 ms 39768 KB Time limit exceeded
38 Incorrect 185 ms 39764 KB Output isn't correct
39 Incorrect 66 ms 39764 KB Output isn't correct
40 Incorrect 202 ms 39876 KB Output isn't correct
41 Execution timed out 1052 ms 39772 KB Time limit exceeded
42 Incorrect 88 ms 39760 KB Output isn't correct