結果
| 問題 | No.617 Nafmo、買い出しに行く | 
| コンテスト | |
| ユーザー |  hiro_metal_core | 
| 提出日時 | 2017-12-19 00:22:12 | 
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 524 ms / 2,000 ms | 
| コード長 | 479 bytes | 
| コンパイル時間 | 437 ms | 
| コンパイル使用メモリ | 12,544 KB | 
| 実行使用メモリ | 10,880 KB | 
| 最終ジャッジ日時 | 2024-12-16 01:01:35 | 
| 合計ジャッジ時間 | 5,109 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 20 | 
ソースコード
N, K = list(map(int, input().split()))
A = []
for n in range(N):
    A.append(int(input()))
def bin_search(item_index, rest_weight):
    if item_index == N:
        return 0
    elif rest_weight < A[item_index]:
        return bin_search(item_index + 1, rest_weight)
    else:
        res1 = bin_search(item_index + 1, rest_weight)
        res2 = bin_search(item_index + 1, rest_weight - A[item_index]) + A[item_index]
        return max(res1, res2)
print(bin_search(0, K))
            
            
            
        