結果

問題 No.617 Nafmo、買い出しに行く
ユーザー Ryuto
提出日時 2017-12-17 18:32:56
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 560 bytes
コンパイル時間 397 ms
コンパイル使用メモリ 82,160 KB
実行使用メモリ 132,864 KB
最終ジャッジ日時 2024-12-15 22:44:09
合計ジャッジ時間 25,736 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 10 WA * 2 TLE * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python

import itertools

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

ans = 0
for perm in itertools.permutations(weights):
    tmp = 0
    for l in perm:
        if tmp + l > indat[1]:
            break
        elif tmp + l == indat[1]:
            print(tmp+l)
            exit()
        elif tmp + l < indat[1]:
            tmp += l
    if tmp > ans:
        ans = tmp

print(ans)
0