結果

問題 No.385 カップ麺生活
ユーザー convexineqconvexineq
提出日時 2021-02-05 05:45:21
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 556 bytes
コンパイル時間 325 ms
コンパイル使用メモリ 87,328 KB
実行使用メモリ 76,996 KB
最終ジャッジ日時 2023-09-14 03:45:26
合計ジャッジ時間 4,607 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
71,708 KB
testcase_01 AC 70 ms
71,816 KB
testcase_02 WA -
testcase_03 AC 68 ms
71,492 KB
testcase_04 AC 80 ms
76,468 KB
testcase_05 AC 71 ms
71,568 KB
testcase_06 AC 77 ms
76,424 KB
testcase_07 WA -
testcase_08 AC 74 ms
76,248 KB
testcase_09 AC 68 ms
71,784 KB
testcase_10 AC 77 ms
76,432 KB
testcase_11 AC 67 ms
71,628 KB
testcase_12 WA -
testcase_13 AC 77 ms
76,484 KB
testcase_14 AC 80 ms
76,660 KB
testcase_15 AC 77 ms
76,664 KB
testcase_16 AC 72 ms
76,368 KB
testcase_17 AC 78 ms
76,488 KB
testcase_18 AC 74 ms
76,600 KB
testcase_19 AC 74 ms
76,480 KB
testcase_20 AC 75 ms
76,488 KB
testcase_21 AC 78 ms
76,644 KB
testcase_22 WA -
testcase_23 AC 79 ms
76,508 KB
testcase_24 AC 78 ms
76,448 KB
testcase_25 AC 68 ms
71,628 KB
testcase_26 AC 78 ms
76,432 KB
testcase_27 AC 80 ms
76,480 KB
testcase_28 AC 77 ms
76,780 KB
testcase_29 AC 74 ms
76,576 KB
testcase_30 AC 79 ms
76,804 KB
testcase_31 AC 68 ms
75,652 KB
testcase_32 AC 74 ms
76,348 KB
testcase_33 AC 77 ms
76,644 KB
testcase_34 AC 78 ms
76,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def Eratosthenes(N): #N以下の素数のリストを返す
    N+=1
    is_prime_list = [True]*N
    m = int(N**0.5)+1
    for i in range(3,m,2):
        if is_prime_list[i]:
            is_prime_list[i*i::2*i]=[False]*((N-i*i-1)//(2*i)+1)
    return [2] + [i for i in range(3,N,2) if is_prime_list[i]]

m,n,*a = map(int,open(0).read().split())
dp = [-10**9]*(m+1)
dp[0] = 0
for ai in a:
    for i in range(ai,m+1):
        dp[i] = max(dp[i],dp[i-ai] + 1)

primes = Eratosthenes(m+1)
ans = 0
for i in primes:
    ans += max(0,dp[m-i])
print(ans + max(dp))
0