結果

問題 No.385 カップ麺生活
ユーザー 双六双六
提出日時 2020-07-29 02:47:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 71 ms / 2,000 ms
コード長 797 bytes
コンパイル時間 524 ms
コンパイル使用メモリ 82,852 KB
実行使用メモリ 72,288 KB
最終ジャッジ日時 2024-04-15 07:41:27
合計ジャッジ時間 3,521 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
63,508 KB
testcase_01 AC 53 ms
63,764 KB
testcase_02 AC 53 ms
63,208 KB
testcase_03 AC 57 ms
65,348 KB
testcase_04 AC 61 ms
67,584 KB
testcase_05 AC 57 ms
66,536 KB
testcase_06 AC 62 ms
68,848 KB
testcase_07 AC 71 ms
71,116 KB
testcase_08 AC 64 ms
69,840 KB
testcase_09 AC 53 ms
63,808 KB
testcase_10 AC 65 ms
70,548 KB
testcase_11 AC 52 ms
63,540 KB
testcase_12 AC 66 ms
71,488 KB
testcase_13 AC 64 ms
70,152 KB
testcase_14 AC 70 ms
71,756 KB
testcase_15 AC 69 ms
71,724 KB
testcase_16 AC 57 ms
65,560 KB
testcase_17 AC 66 ms
72,288 KB
testcase_18 AC 69 ms
70,632 KB
testcase_19 AC 69 ms
71,656 KB
testcase_20 AC 67 ms
70,108 KB
testcase_21 AC 70 ms
72,100 KB
testcase_22 AC 68 ms
70,416 KB
testcase_23 AC 70 ms
71,724 KB
testcase_24 AC 62 ms
68,576 KB
testcase_25 AC 58 ms
66,268 KB
testcase_26 AC 58 ms
65,752 KB
testcase_27 AC 67 ms
71,460 KB
testcase_28 AC 67 ms
71,560 KB
testcase_29 AC 68 ms
71,028 KB
testcase_30 AC 69 ms
72,148 KB
testcase_31 AC 56 ms
64,748 KB
testcase_32 AC 62 ms
68,280 KB
testcase_33 AC 69 ms
71,224 KB
testcase_34 AC 61 ms
68,512 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

num = 10 ** 5 + 1 #適当に値を入れる
L = [1 for i in range(num)]; L[0] = 0; L[1] = 0
plist = []
for i in range(num):
	if L[i] == 1:
		plist.append(i); c = 2
		while i * c <= num - 1:
			L[i * c] = 0; c += 1

#処理内容
def main():
	M = int(input())
	N = int(input())
	C = getlist()
	DP = [-INF] * (M + 1)
	DP[-1] = 0
	for i in range(M, -1, -1):
		for j in C:
			if i - j >= 0:
				DP[i - j] = max(DP[i - j], DP[i] + 1)

	ans = max(DP)
	# print(DP)
	for i in plist:
		if i <= M:
			if DP[i] != -INF:
				ans += DP[i]
		else:
			break

	print(ans)

if __name__ == '__main__':
	main()
0