結果

問題 No.617 Nafmo、買い出しに行く
ユーザー ああいいああいい
提出日時 2021-12-29 18:06:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 386 ms / 2,000 ms
コード長 377 bytes
コンパイル時間 154 ms
コンパイル使用メモリ 82,416 KB
実行使用メモリ 371,076 KB
最終ジャッジ日時 2024-04-14 23:48:03
合計ジャッジ時間 3,660 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
81,880 KB
testcase_01 AC 42 ms
59,736 KB
testcase_02 AC 80 ms
92,328 KB
testcase_03 AC 130 ms
144,756 KB
testcase_04 AC 49 ms
64,836 KB
testcase_05 AC 189 ms
210,540 KB
testcase_06 AC 386 ms
371,076 KB
testcase_07 AC 333 ms
370,824 KB
testcase_08 AC 38 ms
52,592 KB
testcase_09 AC 37 ms
53,092 KB
testcase_10 AC 267 ms
281,176 KB
testcase_11 AC 305 ms
328,416 KB
testcase_12 AC 195 ms
204,848 KB
testcase_13 AC 145 ms
146,996 KB
testcase_14 AC 171 ms
173,804 KB
testcase_15 AC 43 ms
59,976 KB
testcase_16 AC 43 ms
61,328 KB
testcase_17 AC 37 ms
52,868 KB
testcase_18 AC 37 ms
52,632 KB
testcase_19 AC 38 ms
52,980 KB
testcase_20 AC 37 ms
53,608 KB
testcase_21 AC 38 ms
52,096 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

dp = [[0] * (K+1) for _ in range(N)]
dp[0][0] = 1
if A[0] <= K:
    dp[0][A[0]] = 1
for i in range(N-1):
    for j in range(K + 1):
        if dp[i][j]:
            dp[i+1][j] = 1
            if j + A[i+1] <= K:
                dp[i+1][j + A[i+1]] = 1
ans = K
while dp[N-1][ans] == 0:
    ans -= 1
print(ans)
0