結果

問題 No.90 品物の並び替え
ユーザー Mr.FukuMr.Fuku
提出日時 2018-06-26 21:48:13
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 2,978 ms / 5,000 ms
コード長 524 bytes
コンパイル時間 89 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 53,760 KB
最終ジャッジ日時 2024-06-30 22:58:54
合計ジャッジ時間 4,528 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools

n,m = input().split()
n,m = int(n),int(m)

lst = []
allpoint = 0
for i in range(m):
    l = list(map(int,input().split()))
    lst.append([l[2]]+l[:2])
    allpoint += l[2]
lst.sort()
lst.reverse()
l = list(range(n))

minpoint = allpoint

for a in list(itertools.permutations(l)):
    nowpoint = 0
    for b in lst:
        if a[b[1]]<a[b[2]]:
            nowpoint += b[0]
            if nowpoint>minpoint:
                break
    else:
        minpoint = min(minpoint,nowpoint)

print(allpoint-minpoint)
0