結果

問題 No.90 品物の並び替え
ユーザー Mr.FukuMr.Fuku
提出日時 2018-06-26 21:48:13
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 2,858 ms / 5,000 ms
コード長 524 bytes
コンパイル時間 91 ms
コンパイル使用メモリ 10,928 KB
実行使用メモリ 51,012 KB
最終ジャッジ日時 2023-09-13 14:13:43
合計ジャッジ時間 4,385 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
8,168 KB
testcase_01 AC 167 ms
12,892 KB
testcase_02 AC 16 ms
8,208 KB
testcase_03 AC 26 ms
8,772 KB
testcase_04 AC 41 ms
8,588 KB
testcase_05 AC 257 ms
12,912 KB
testcase_06 AC 181 ms
13,084 KB
testcase_07 AC 18 ms
8,280 KB
testcase_08 AC 16 ms
8,216 KB
testcase_09 AC 2,858 ms
51,012 KB
権限があれば一括ダウンロードができます

ソースコード

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