結果

問題 No.617 Nafmo、買い出しに行く
ユーザー ああいいああいい
提出日時 2021-12-29 18:03:51
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 374 bytes
コンパイル時間 147 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 323,472 KB
最終ジャッジ日時 2024-04-14 23:45:24
合計ジャッジ時間 3,839 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 29 ms
10,880 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 27 ms
10,752 KB
testcase_09 AC 25 ms
10,880 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 AC 42 ms
11,520 KB
testcase_16 AC 51 ms
12,032 KB
testcase_17 AC 25 ms
10,752 KB
testcase_18 AC 26 ms
10,880 KB
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
権限があれば一括ダウンロードができます

ソースコード

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[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