結果

問題 No.385 カップ麺生活
ユーザー ynyn
提出日時 2016-07-02 14:07:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 63 ms / 2,000 ms
コード長 714 bytes
コンパイル時間 260 ms
コンパイル使用メモリ 82,576 KB
実行使用メモリ 68,396 KB
最終ジャッジ日時 2024-04-15 07:30:49
合計ジャッジ時間 3,152 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
60,168 KB
testcase_01 AC 43 ms
61,128 KB
testcase_02 AC 42 ms
59,972 KB
testcase_03 AC 45 ms
59,496 KB
testcase_04 AC 52 ms
63,528 KB
testcase_05 AC 44 ms
60,244 KB
testcase_06 AC 57 ms
65,576 KB
testcase_07 AC 53 ms
64,788 KB
testcase_08 AC 53 ms
63,612 KB
testcase_09 AC 41 ms
58,320 KB
testcase_10 AC 63 ms
66,400 KB
testcase_11 AC 41 ms
59,004 KB
testcase_12 AC 52 ms
64,612 KB
testcase_13 AC 60 ms
66,936 KB
testcase_14 AC 59 ms
67,112 KB
testcase_15 AC 55 ms
66,056 KB
testcase_16 AC 48 ms
61,392 KB
testcase_17 AC 63 ms
66,744 KB
testcase_18 AC 54 ms
64,388 KB
testcase_19 AC 52 ms
63,276 KB
testcase_20 AC 60 ms
66,320 KB
testcase_21 AC 57 ms
66,200 KB
testcase_22 AC 56 ms
66,632 KB
testcase_23 AC 61 ms
68,396 KB
testcase_24 AC 61 ms
67,472 KB
testcase_25 AC 45 ms
61,076 KB
testcase_26 AC 47 ms
61,556 KB
testcase_27 AC 61 ms
67,760 KB
testcase_28 AC 61 ms
67,076 KB
testcase_29 AC 55 ms
65,268 KB
testcase_30 AC 60 ms
67,416 KB
testcase_31 AC 46 ms
60,924 KB
testcase_32 AC 50 ms
63,112 KB
testcase_33 AC 57 ms
65,528 KB
testcase_34 AC 49 ms
63,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

m = int(input())
n = int(input())
c = list(map(int,input().split()))
c.sort(reverse=True)

prime = []
table = [True] * (m + 1)
table[0] = table[1]  = False

for i in range(2, m + 1):
    if not table[i]:
        continue
    k = i + i
    while k < m + 1:
        table[k] = False
        k += i

    prime.append(i)

divp = [False] * 10001
divpnum = []
for i in range(len(prime)):
    divp[m - prime[i]] = True
    divpnum.append(m - prime[i])

cost = [-1] * 20001
cost[0] = 0

for i in range(20001):
    for C in c:
        if cost[i] >= 0 and i + C <= m:
            cost[i + C] = max(cost[i] + 1, cost[i + C])

ans = 0
for i in divpnum:
    if cost[i] >= 0:
        ans += cost[i]

ans += m // c[-1]
print(ans)
0