結果

問題 No.385 カップ麺生活
ユーザー tookunn_1213tookunn_1213
提出日時 2016-07-02 13:36:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 60 ms / 2,000 ms
コード長 513 bytes
コンパイル時間 491 ms
コンパイル使用メモリ 82,492 KB
実行使用メモリ 66,884 KB
最終ジャッジ日時 2024-04-15 07:30:46
合計ジャッジ時間 3,212 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
52,552 KB
testcase_01 AC 40 ms
53,468 KB
testcase_02 AC 39 ms
53,312 KB
testcase_03 AC 43 ms
58,116 KB
testcase_04 AC 51 ms
62,280 KB
testcase_05 AC 45 ms
59,948 KB
testcase_06 AC 56 ms
64,396 KB
testcase_07 AC 56 ms
64,632 KB
testcase_08 AC 52 ms
63,440 KB
testcase_09 AC 38 ms
52,456 KB
testcase_10 AC 60 ms
64,420 KB
testcase_11 AC 38 ms
53,600 KB
testcase_12 AC 53 ms
64,800 KB
testcase_13 AC 57 ms
64,564 KB
testcase_14 AC 57 ms
65,984 KB
testcase_15 AC 57 ms
64,652 KB
testcase_16 AC 43 ms
59,484 KB
testcase_17 AC 57 ms
65,436 KB
testcase_18 AC 52 ms
62,924 KB
testcase_19 AC 53 ms
65,300 KB
testcase_20 AC 55 ms
65,136 KB
testcase_21 AC 58 ms
66,792 KB
testcase_22 AC 56 ms
65,308 KB
testcase_23 AC 58 ms
65,348 KB
testcase_24 AC 56 ms
65,508 KB
testcase_25 AC 43 ms
58,244 KB
testcase_26 AC 53 ms
62,576 KB
testcase_27 AC 55 ms
64,320 KB
testcase_28 AC 55 ms
64,576 KB
testcase_29 AC 56 ms
65,416 KB
testcase_30 AC 58 ms
66,080 KB
testcase_31 AC 47 ms
60,084 KB
testcase_32 AC 50 ms
61,124 KB
testcase_33 AC 57 ms
66,884 KB
testcase_34 AC 51 ms
62,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

M,N= int(input()),int(input())
C = sorted([int(i) for i in input().split()])
prime = [True for i in range(M + 1)]
prime[0] = prime[1] = False
dp = [-1 for i in range(M + 1)]
for i in range(2,M + 1):
	if prime[i]:
		j = 2
		while i * j <= M:
			prime[i * j] = False
			j+=1
dp[M] = 0
for i in range(N):
	for j in range(M,-1,-1):
		if dp[j] != -1 and j - C[i] >= 0:
			dp[j - C[i]] = max(dp[j - C[i]],dp[j] + 1)
ans = 0
for i in range(M + 1):
	if prime[i] and dp[i] >= 0:
		ans += dp[i]
ans += M // C[0]
print(ans)
0