結果
問題 | No.617 Nafmo、買い出しに行く |
ユーザー |
|
提出日時 | 2017-12-18 20:24:48 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 129 ms / 2,000 ms |
コード長 | 457 bytes |
コンパイル時間 | 456 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 75,648 KB |
最終ジャッジ日時 | 2024-12-16 00:29:04 |
合計ジャッジ時間 | 2,776 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 20 |
ソースコード
#!/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 == len(weights): 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]))