結果

問題 No.90 品物の並び替え
ユーザー ronpooronpoo
提出日時 2023-08-22 15:40:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 420 ms / 5,000 ms
コード長 374 bytes
コンパイル時間 308 ms
コンパイル使用メモリ 87,180 KB
実行使用メモリ 77,156 KB
最終ジャッジ日時 2023-08-22 15:40:22
合計ジャッジ時間 2,398 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,552 KB
testcase_01 AC 112 ms
76,936 KB
testcase_02 AC 70 ms
71,152 KB
testcase_03 AC 82 ms
76,672 KB
testcase_04 AC 84 ms
76,592 KB
testcase_05 AC 113 ms
77,156 KB
testcase_06 AC 106 ms
76,992 KB
testcase_07 AC 87 ms
76,720 KB
testcase_08 AC 71 ms
71,400 KB
testcase_09 AC 420 ms
77,132 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import permutations

N, M = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(M)]

ans = 0
for p in permutations(range(N)):
    score = 0
    d = [0] * N
    for i, v in enumerate(p):
        d[v] = i
    for i in range(M):
        x, y, z = A[i]
        if d[x] < d[y]:
            score += z
    ans = max(ans, score)

print(ans)
0