結果

問題 No.617 Nafmo、買い出しに行く
ユーザー RyutoRyuto
提出日時 2017-12-18 20:20:33
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 453 bytes
コンパイル時間 322 ms
コンパイル使用メモリ 86,732 KB
実行使用メモリ 78,964 KB
最終ジャッジ日時 2023-08-22 05:50:51
合計ジャッジ時間 4,150 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,252 KB
testcase_01 RE -
testcase_02 AC 89 ms
75,324 KB
testcase_03 AC 99 ms
76,500 KB
testcase_04 AC 74 ms
71,088 KB
testcase_05 AC 99 ms
76,344 KB
testcase_06 AC 112 ms
76,500 KB
testcase_07 AC 111 ms
76,800 KB
testcase_08 RE -
testcase_09 RE -
testcase_10 AC 111 ms
76,312 KB
testcase_11 AC 111 ms
76,340 KB
testcase_12 AC 120 ms
76,560 KB
testcase_13 AC 143 ms
76,676 KB
testcase_14 AC 123 ms
76,564 KB
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 AC 74 ms
71,352 KB
testcase_20 AC 73 ms
71,116 KB
testcase_21 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python

indat = [int(x) for x in input().split()]
weights = list()
for i in range(indat[0]):
    x = int(input())
    if x < indat[1]:
        weights.append(x)
    elif x == indat[1]:
        print(x)
        exit()

def rec(i,j):
    if i == indat[0]:
        res = 0
    elif j < weights[i]:
        res = rec(i+1,j)
    else:
        res = max(rec(i+1, j), rec(i+1, j-weights[i]) + weights[i])
    return res

print(rec(0, indat[1]))
0