結果

問題 No.617 Nafmo、買い出しに行く
ユーザー naotomannaotoman
提出日時 2018-07-15 20:44:07
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 356 bytes
コンパイル時間 136 ms
コンパイル使用メモリ 10,928 KB
実行使用メモリ 28,288 KB
最終ジャッジ日時 2023-08-07 01:15:09
合計ジャッジ時間 7,636 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 251 ms
15,376 KB
testcase_01 AC 16 ms
7,836 KB
testcase_02 AC 335 ms
10,848 KB
testcase_03 AC 960 ms
13,468 KB
testcase_04 AC 63 ms
9,088 KB
testcase_05 AC 1,706 ms
16,912 KB
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)
        break
    
0