結果

問題 No.617 Nafmo、買い出しに行く
ユーザー naotomannaotoman
提出日時 2018-07-15 20:29:03
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 342 bytes
コンパイル時間 112 ms
コンパイル使用メモリ 10,900 KB
実行使用メモリ 28,432 KB
最終ジャッジ日時 2023-08-06 23:13:41
合計ジャッジ時間 7,787 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N, K = map(int, input().split())
seqA = [int(input()) for _ in range(N)]
seqA.sort(reverse=True)
dp = [False for _ in range(K+1)]
dp[0] = True
for a in seqA:
    for i in range(K, a-1, -1):
        if dp[i] and i+a<=K:
            dp[i+a] = True
    if a <= K:
        dp[a] = True
for i in range(K+1):
    if dp[K-i]:
        print(K-i)
    
0