結果

問題 No.617 Nafmo、買い出しに行く
ユーザー r2en_r2en_
提出日時 2017-12-21 15:56:37
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 454 ms / 2,000 ms
コード長 1,116 bytes
コンパイル時間 309 ms
コンパイル使用メモリ 10,908 KB
実行使用メモリ 8,740 KB
最終ジャッジ日時 2023-08-22 20:45:39
合計ジャッジ時間 5,496 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
8,740 KB
testcase_01 AC 20 ms
8,568 KB
testcase_02 AC 21 ms
8,584 KB
testcase_03 AC 46 ms
8,664 KB
testcase_04 AC 20 ms
8,692 KB
testcase_05 AC 72 ms
8,648 KB
testcase_06 AC 453 ms
8,724 KB
testcase_07 AC 453 ms
8,680 KB
testcase_08 AC 20 ms
8,584 KB
testcase_09 AC 20 ms
8,664 KB
testcase_10 AC 450 ms
8,620 KB
testcase_11 AC 450 ms
8,596 KB
testcase_12 AC 454 ms
8,692 KB
testcase_13 AC 418 ms
8,616 KB
testcase_14 AC 451 ms
8,692 KB
testcase_15 AC 262 ms
8,584 KB
testcase_16 AC 262 ms
8,616 KB
testcase_17 AC 262 ms
8,592 KB
testcase_18 AC 20 ms
8,648 KB
testcase_19 AC 20 ms
8,696 KB
testcase_20 AC 21 ms
8,568 KB
testcase_21 AC 20 ms
8,620 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import time
import itertools
import collections
from functools import reduce
from functools import wraps
from collections import defaultdict
# import pdb; pdb.set_trace()

def timefn(fn):
    @wraps(fn)
    def measure_time(*args, **kwargs):
        t1 = time.time()
        res = fn(*args, *kwargs)
        t2 = time.time()
        print('@timefn:' + fn.__name__ + ' took ' + str(t2-t1) + ' seconds.')
        return res
    return measure_time


#def fn(*args, **kwargs):
#@timefn
#@profile
def fn():
    # m, n = (int(i) for i in input().split())
    # a = [int(input()) for _ in range(n)]
    m, n = map(int, input().split())
    a = tuple(int(input()) for _ in [0] * m)

    # m, n, a = 4, 4, [1, 2, 3, 5]
    # m, n, a = 8, 341274, (2999, 92754, 57910, 35884, 75405, 30284, 12530, 392345)

    #print('m:{0} n:{1} a:{2}'.format(type(m), type(n), type(a)))

    weight = 0
    for i in range(1, m + 1):
        com = itertools.combinations(a, i)
        for perm in com:
            w = sum(perm)
            if w <= n: weight = max(w, weight)

    print('{0}'.format(weight))

if __name__ == "__main__": fn()

0