답안 #44317

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
44317 2018-03-31T11:22:52 Z neutron_byte Brunhilda’s Birthday (BOI13_brunhilda) C++17
0 / 100
3 ms 952 KB
#include <bits/stdc++.h>
#define INF 1000000000
using namespace std;

const int n = 10 * 1000 * 1000;

int main() {
    int m, q, x;
    cin >> m >> q;

    int prime[m];
    for (int i = 0; i < m; ++i) {
        cin >> prime[i];
    }

    int dp[n + 1];
    dp[0] = 0;

    int updated[m];
    fill(updated, updated + m, 0);

    vector<int> current[n + 1];
    for (int i = 0; i < m; ++i) {
        for (int j = 1; prime[i] * j <= n; ++j) {
            current[prime[i] * j].push_back(i);
        }
    }

    for (int i = 1; i <= n; ++i) {
        for (int pIdx : current[i]) {
            updated[pIdx] = i;
        }

        int bestVal = INF;
        for (int j = 0; j < m; ++j) {
            bestVal = min(bestVal, updated[j]);
        }

        if (bestVal >= i) dp[i] = INF;
        else dp[i] = 1 + dp[bestVal];
    }

    while (q--) {
        cin >> x;
        cout << (dp[x] < INF ? to_string(dp[x]) : "oo") << endl;
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 2 ms 684 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 2 ms 684 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 2 ms 792 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 3 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 3 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
21 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
22 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
23 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
24 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
25 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
26 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
27 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
28 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
29 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
30 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
31 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
32 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
33 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
34 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
35 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
36 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
37 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
38 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
39 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
40 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
41 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
42 Runtime error 2 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)