結果

問題 No.385 カップ麺生活
ユーザー fumofumofunifumofumofuni
提出日時 2021-09-13 20:24:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 111 ms / 2,000 ms
コード長 481 bytes
コンパイル時間 296 ms
コンパイル使用メモリ 87,132 KB
実行使用メモリ 77,944 KB
最終ジャッジ日時 2023-09-08 04:07:19
合計ジャッジ時間 5,890 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 94 ms
77,700 KB
testcase_01 AC 88 ms
77,764 KB
testcase_02 AC 88 ms
77,652 KB
testcase_03 AC 94 ms
77,640 KB
testcase_04 AC 90 ms
77,748 KB
testcase_05 AC 98 ms
77,840 KB
testcase_06 AC 96 ms
77,720 KB
testcase_07 AC 93 ms
77,524 KB
testcase_08 AC 99 ms
77,748 KB
testcase_09 AC 84 ms
77,668 KB
testcase_10 AC 98 ms
77,740 KB
testcase_11 AC 85 ms
77,624 KB
testcase_12 AC 109 ms
77,828 KB
testcase_13 AC 98 ms
77,756 KB
testcase_14 AC 95 ms
77,944 KB
testcase_15 AC 99 ms
77,728 KB
testcase_16 AC 97 ms
77,656 KB
testcase_17 AC 107 ms
77,872 KB
testcase_18 AC 106 ms
77,724 KB
testcase_19 AC 100 ms
77,680 KB
testcase_20 AC 105 ms
77,640 KB
testcase_21 AC 96 ms
77,796 KB
testcase_22 AC 101 ms
77,864 KB
testcase_23 AC 99 ms
77,688 KB
testcase_24 AC 96 ms
77,800 KB
testcase_25 AC 94 ms
77,520 KB
testcase_26 AC 87 ms
77,508 KB
testcase_27 AC 95 ms
77,696 KB
testcase_28 AC 93 ms
77,768 KB
testcase_29 AC 95 ms
77,792 KB
testcase_30 AC 99 ms
77,748 KB
testcase_31 AC 91 ms
77,724 KB
testcase_32 AC 93 ms
77,808 KB
testcase_33 AC 111 ms
77,764 KB
testcase_34 AC 93 ms
77,692 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

maxN=100010
dp=[-100010]*maxN
dp[0]=0
N=int(input())
K=int(input())
A=list(map(int,input().split()))
list.sort(A)
for i in range(K):
    for j in range(maxN):
        if j+A[i]<maxN:
            dp[j+A[i]]=max(dp[j+A[i]],dp[j]+1)
prime=[1]*maxN
prime[0]=0
prime[1]=0
for i in range(2,maxN):
    if not i:
        continue
    j=i+i
    while j<maxN:
        prime[j]=0
        j+=i

ans=0
for i in range(N+1):
    if prime[i] and dp[N-i]>0:
        ans+=dp[N-i]
print(ans+N//A[0])
0