結果

問題 No.90 品物の並び替え
ユーザー mationaruzoumationaruzou
提出日時 2020-06-20 01:46:00
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 465 bytes
コンパイル時間 92 ms
コンパイル使用メモリ 10,888 KB
実行使用メモリ 8,320 KB
最終ジャッジ日時 2023-09-16 16:29:38
合計ジャッジ時間 9,294 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,272 KB
testcase_01 AC 621 ms
8,124 KB
testcase_02 AC 15 ms
8,256 KB
testcase_03 AC 71 ms
8,212 KB
testcase_04 AC 72 ms
8,168 KB
testcase_05 AC 601 ms
8,088 KB
testcase_06 AC 618 ms
8,320 KB
testcase_07 AC 22 ms
8,172 KB
testcase_08 AC 15 ms
8,304 KB
testcase_09 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import permutations
n, m = map(int, input().split())
value = [[0]*(n+1) for _ in range(n+1)]

for i in range(m):
    a, b, c = map(int, input().split())
    value[a][b] = c
ans = 0
for s in permutations(range(n), n):
    num = 0
    for i in range(n-1):
        for j in range(i+1, n):
            if s.index(i) < s.index(j):
                num += value[i][j]
            else:
                num += value[j][i]
    ans = max(ans, num)

print(ans)
0