結果

問題 No.90 品物の並び替え
ユーザー 👑 KazunKazun
提出日時 2020-10-14 16:12:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 428 ms / 5,000 ms
コード長 360 bytes
コンパイル時間 863 ms
コンパイル使用メモリ 86,988 KB
実行使用メモリ 77,148 KB
最終ジャッジ日時 2023-09-28 00:38:30
合計ジャッジ時間 2,633 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,640 KB
testcase_01 AC 103 ms
76,596 KB
testcase_02 AC 68 ms
71,352 KB
testcase_03 AC 80 ms
76,528 KB
testcase_04 AC 80 ms
76,528 KB
testcase_05 AC 108 ms
76,640 KB
testcase_06 AC 99 ms
76,488 KB
testcase_07 AC 81 ms
76,388 KB
testcase_08 AC 70 ms
71,320 KB
testcase_09 AC 428 ms
77,148 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import permutations

N,M=map(int,input().split())
X=[0]*M
for i in range(M):
    x,y,a=map(int,input().split())
    X[i]=(x,y,a)

Max=-1
Index=[0]*N
for U in permutations(range(N)):
    T=0

    for i in range(N):
        Index[U[i]]=i

    for (x,y,a) in X:
        if Index[x]<Index[y]:
            T+=a

    if T>Max:
        Max=T
print(Max)
0