結果

問題 No.385 カップ麺生活
ユーザー mkawa2mkawa2
提出日時 2020-03-27 16:45:27
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,135 bytes
コンパイル時間 124 ms
コンパイル使用メモリ 11,100 KB
実行使用メモリ 9,184 KB
最終ジャッジ日時 2023-08-30 16:28:23
合計ジャッジ時間 2,918 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
8,832 KB
testcase_01 AC 20 ms
8,732 KB
testcase_02 AC 20 ms
8,712 KB
testcase_03 AC 21 ms
8,876 KB
testcase_04 AC 24 ms
8,872 KB
testcase_05 AC 21 ms
8,916 KB
testcase_06 WA -
testcase_07 AC 26 ms
8,940 KB
testcase_08 AC 23 ms
8,768 KB
testcase_09 AC 20 ms
8,712 KB
testcase_10 AC 77 ms
9,064 KB
testcase_11 AC 19 ms
8,908 KB
testcase_12 AC 27 ms
8,772 KB
testcase_13 AC 35 ms
8,936 KB
testcase_14 AC 37 ms
9,112 KB
testcase_15 AC 35 ms
8,940 KB
testcase_16 AC 21 ms
8,852 KB
testcase_17 AC 47 ms
8,912 KB
testcase_18 AC 27 ms
8,932 KB
testcase_19 AC 23 ms
8,764 KB
testcase_20 AC 36 ms
8,924 KB
testcase_21 AC 39 ms
8,808 KB
testcase_22 AC 36 ms
8,928 KB
testcase_23 AC 41 ms
8,844 KB
testcase_24 AC 38 ms
9,036 KB
testcase_25 AC 21 ms
8,748 KB
testcase_26 AC 24 ms
9,184 KB
testcase_27 AC 31 ms
8,996 KB
testcase_28 AC 33 ms
9,036 KB
testcase_29 AC 26 ms
8,956 KB
testcase_30 AC 38 ms
8,968 KB
testcase_31 AC 20 ms
8,856 KB
testcase_32 AC 22 ms
8,848 KB
testcase_33 AC 43 ms
8,748 KB
testcase_34 AC 24 ms
8,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10 ** 6)
from bisect import *
from collections import *
from heapq import *

def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def SI(): return sys.stdin.readline()[:-1]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
int1 = lambda x: int(x) - 1
def MI1(): return map(int1, sys.stdin.readline().split())
def LI1(): return list(map(int1, sys.stdin.readline().split()))
p2D = lambda x: print(*x, sep="\n")
dij = [(1, 0), (0, 1), (-1, 0), (0, -1)]

def main():
    inf=10**9
    m=II()
    n=II()
    cc=LI()
    isprime=[True]*10005
    isprime[0]=isprime[1]=False
    for a in range(2,10005):
        if a**2>10005:break
        if not isprime[a]:continue
        for b in range(a*a,10005,a):
            isprime[b]=False
    dp=[-inf]*(m+1)
    dp[0]=0
    for i in range(1,m+1):
        for c in cc:
            if i-c>=0:dp[i]=max(dp[i],dp[i-c]+1)
    ans=max(dp)
    for i in range(2,m):
        if isprime[m-i] and dp[i]>0:
            ans+=dp[i]
    print(ans)

main()
0