結果

問題 No.617 Nafmo、買い出しに行く
ユーザー iad_2889iad_2889
提出日時 2019-05-16 13:47:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 692 ms / 2,000 ms
コード長 368 bytes
コンパイル時間 1,145 ms
コンパイル使用メモリ 81,404 KB
実行使用メモリ 387,000 KB
最終ジャッジ日時 2023-10-17 06:52:15
合計ジャッジ時間 5,832 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 100 ms
85,524 KB
testcase_01 AC 46 ms
61,472 KB
testcase_02 AC 125 ms
97,448 KB
testcase_03 AC 215 ms
151,936 KB
testcase_04 AC 63 ms
68,260 KB
testcase_05 AC 364 ms
222,248 KB
testcase_06 AC 692 ms
386,388 KB
testcase_07 AC 643 ms
387,000 KB
testcase_08 AC 38 ms
52,956 KB
testcase_09 AC 37 ms
52,956 KB
testcase_10 AC 501 ms
292,700 KB
testcase_11 AC 590 ms
341,772 KB
testcase_12 AC 353 ms
214,648 KB
testcase_13 AC 224 ms
151,684 KB
testcase_14 AC 273 ms
180,580 KB
testcase_15 AC 44 ms
59,076 KB
testcase_16 AC 51 ms
63,340 KB
testcase_17 AC 38 ms
52,956 KB
testcase_18 AC 38 ms
52,956 KB
testcase_19 AC 38 ms
52,956 KB
testcase_20 AC 38 ms
52,956 KB
testcase_21 AC 38 ms
52,956 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K = map(int,input().split())
products = [int(input()) for x in range(N)]

products.sort()
dp = [[0 for x in range(K + 1)] for y in range(N + 1)]
for i,p in enumerate(products):
    before = dp[i]
    for w in range(K + 1):
        if w < p:
            dp[i+1][w] = before[w]
        else:
            dp[i+1][w] = max(before[w],before[w - p] + p)

print(dp[-1][-1])
0