結果

問題 No.617 Nafmo、買い出しに行く
ユーザー kryu_______2740
提出日時 2018-02-22 15:30:53
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 885 ms / 2,000 ms
コード長 582 bytes
コンパイル時間 220 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 59,188 KB
最終ジャッジ日時 2024-10-01 12:36:20
合計ジャッジ時間 9,442 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

# combinationの勉強

import itertools as it
#N[0]は個数,N[1]がmaxweight

N = list(map(int,input().split()))
A = [0]*N[0]
for i in range(N[0]):
    A[i] = int(input())

combi = list(it.combinations(A,0))

#print(combi)


ans = 0
weight = 0

for i in range(N[0]):
    combi = list(it.combinations(A,i+1))#nCnにおいて後ろのnが1より大きくないと何もcombiしない
    #print(combi)
    for j in range(len(combi)):
        weight = sum(combi[j])
        #print(weight)
        if (ans<=weight)and(weight<=N[1]):
            ans = weight

            
print(ans)

0