結果

問題 No.385 カップ麺生活
ユーザー 👑 rin204rin204
提出日時 2022-07-10 14:55:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 95 ms / 2,000 ms
コード長 497 bytes
コンパイル時間 322 ms
コンパイル使用メモリ 87,348 KB
実行使用メモリ 78,468 KB
最終ジャッジ日時 2023-09-01 03:22:44
合計ジャッジ時間 5,445 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
77,648 KB
testcase_01 AC 82 ms
77,676 KB
testcase_02 AC 80 ms
78,120 KB
testcase_03 AC 82 ms
77,648 KB
testcase_04 AC 95 ms
78,164 KB
testcase_05 AC 83 ms
77,856 KB
testcase_06 AC 89 ms
78,244 KB
testcase_07 AC 87 ms
78,168 KB
testcase_08 AC 88 ms
77,964 KB
testcase_09 AC 83 ms
77,640 KB
testcase_10 AC 87 ms
78,172 KB
testcase_11 AC 80 ms
77,816 KB
testcase_12 AC 86 ms
78,248 KB
testcase_13 AC 85 ms
77,984 KB
testcase_14 AC 88 ms
78,300 KB
testcase_15 AC 86 ms
78,468 KB
testcase_16 AC 83 ms
77,924 KB
testcase_17 AC 92 ms
78,252 KB
testcase_18 AC 92 ms
78,068 KB
testcase_19 AC 91 ms
78,232 KB
testcase_20 AC 92 ms
78,216 KB
testcase_21 AC 88 ms
77,984 KB
testcase_22 AC 90 ms
78,276 KB
testcase_23 AC 89 ms
77,988 KB
testcase_24 AC 95 ms
78,408 KB
testcase_25 AC 79 ms
77,824 KB
testcase_26 AC 84 ms
78,220 KB
testcase_27 AC 91 ms
78,300 KB
testcase_28 AC 88 ms
78,252 KB
testcase_29 AC 87 ms
78,024 KB
testcase_30 AC 87 ms
78,208 KB
testcase_31 AC 84 ms
78,116 KB
testcase_32 AC 86 ms
78,408 KB
testcase_33 AC 87 ms
78,332 KB
testcase_34 AC 87 ms
78,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = 200000
isprime = [True] * N
isprime[0] = isprime[1] = False
for i in range(2, int(N ** 0.5 + 1)):
    if not isprime[i]:
        continue
    for j in range(i * i, N, i):
        isprime[j] = False

m = int(input())
n = int(input())
C = list(map(int, input().split()))
dp = [-1 << 30] * (m + 1)
dp[0] = 0
for c in C:
    for i in range(m - c + 1):
        dp[i + c] = max(dp[i + c], dp[i] + 1)
ans = max(dp)
for i in range(m + 1):
    if isprime[m - i]:
        ans += max(0, dp[i])
print(ans)
0