답안 #138405

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
138405 2019-07-29T21:05:46 Z silxikys Brunhilda’s Birthday (BOI13_brunhilda) C++14
21.4286 / 100
52 ms 36724 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const int maxn = 1e5+5, INF = 2e9+9;
int m, Q;

int dp[10000005];

vector<int> primes;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> m >> Q;
    for (int i = 0; i < m; i++) {
        int p; cin >> p;
        primes.push_back(p);
    }
    sort(primes.begin(),primes.end());
    int maxPrime = primes.back();
    for (int i = 1; i < maxPrime; i++) {
        dp[i] = 1;
    }
    for (int i = maxPrime; i <= 10000; i++) {
        dp[i] = INF;    
        for (int j: primes) {
            //cout << i << ' ' << j << ": " << (i-(i%j)) << '\n';
            dp[i] = min(dp[i],1+dp[i-(i%j)]);
        }
    }

    /*
    for (int i = 1; i <= 10; i++) {
        cout << i << ": " << dp[i] << '\n';
    }
    */
    while (Q--) {
        int qi; cin >> qi;
        if (dp[qi] == INF) cout << "oo\n";
        else cout << dp[qi] << '\n';
    }
}

# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 6 ms 504 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 6 ms 380 KB Output is correct
13 Correct 8 ms 376 KB Output is correct
14 Correct 9 ms 504 KB Output is correct
15 Correct 4 ms 376 KB Output is correct
16 Correct 4 ms 376 KB Output is correct
17 Correct 6 ms 504 KB Output is correct
18 Correct 6 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 4092 KB Output isn't correct
2 Incorrect 45 ms 36692 KB Output isn't correct
3 Incorrect 20 ms 10996 KB Output isn't correct
4 Incorrect 3 ms 760 KB Output isn't correct
5 Incorrect 14 ms 6112 KB Output isn't correct
6 Incorrect 2 ms 660 KB Output isn't correct
7 Incorrect 7 ms 4088 KB Output isn't correct
8 Incorrect 2 ms 504 KB Output isn't correct
9 Incorrect 16 ms 6388 KB Output isn't correct
10 Incorrect 20 ms 10996 KB Output isn't correct
11 Incorrect 10 ms 4472 KB Output isn't correct
12 Incorrect 2 ms 632 KB Output isn't correct
13 Incorrect 4 ms 2296 KB Output isn't correct
14 Incorrect 3 ms 760 KB Output isn't correct
15 Incorrect 10 ms 4088 KB Output isn't correct
16 Incorrect 45 ms 36724 KB Output isn't correct
17 Incorrect 2 ms 632 KB Output isn't correct
18 Incorrect 33 ms 20980 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 26 ms 5368 KB Output isn't correct
2 Incorrect 27 ms 4060 KB Output isn't correct
3 Incorrect 24 ms 5368 KB Output isn't correct
4 Incorrect 33 ms 1756 KB Output isn't correct
5 Incorrect 52 ms 19964 KB Output isn't correct
6 Incorrect 35 ms 1912 KB Output isn't correct
7 Incorrect 39 ms 13364 KB Output isn't correct
8 Incorrect 26 ms 5368 KB Output isn't correct
9 Incorrect 26 ms 5368 KB Output isn't correct
10 Incorrect 14 ms 1016 KB Output isn't correct
11 Incorrect 18 ms 1016 KB Output isn't correct
12 Incorrect 18 ms 1144 KB Output isn't correct
13 Incorrect 27 ms 4728 KB Output isn't correct
14 Incorrect 22 ms 1272 KB Output isn't correct
15 Incorrect 19 ms 1016 KB Output isn't correct
16 Incorrect 18 ms 1016 KB Output isn't correct
17 Incorrect 21 ms 4344 KB Output isn't correct
18 Incorrect 27 ms 4092 KB Output isn't correct
19 Incorrect 20 ms 3420 KB Output isn't correct
20 Incorrect 23 ms 5368 KB Output isn't correct
21 Incorrect 27 ms 1300 KB Output isn't correct
22 Incorrect 45 ms 8436 KB Output isn't correct
23 Incorrect 33 ms 5724 KB Output isn't correct
24 Incorrect 34 ms 1784 KB Output isn't correct
25 Incorrect 42 ms 1584 KB Output isn't correct
26 Incorrect 34 ms 1656 KB Output isn't correct
27 Incorrect 34 ms 8440 KB Output isn't correct
28 Incorrect 24 ms 2168 KB Output isn't correct
29 Incorrect 45 ms 8436 KB Output isn't correct
30 Incorrect 40 ms 6132 KB Output isn't correct
31 Incorrect 36 ms 2540 KB Output isn't correct
32 Incorrect 35 ms 1756 KB Output isn't correct
33 Incorrect 34 ms 2168 KB Output isn't correct
34 Incorrect 37 ms 13300 KB Output isn't correct
35 Incorrect 23 ms 2040 KB Output isn't correct
36 Incorrect 52 ms 8432 KB Output isn't correct
37 Incorrect 52 ms 19956 KB Output isn't correct
38 Incorrect 35 ms 1896 KB Output isn't correct
39 Incorrect 35 ms 1912 KB Output isn't correct
40 Incorrect 35 ms 2296 KB Output isn't correct
41 Correct 51 ms 30896 KB Output is correct
42 Incorrect 23 ms 1700 KB Output isn't correct