結果

問題 No.90 品物の並び替え
ユーザー lloyzlloyz
提出日時 2022-06-13 21:16:50
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 385 bytes
コンパイル時間 90 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 9,984 KB
最終ジャッジ日時 2024-04-08 17:26:10
合計ジャッジ時間 2,852 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
9,984 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import permutations

n, m = map(int, input().split())
C = [[-1 for _ in range(n)] for _ in range(n)]
for _ in range(m):
    i, j, c = map(int, input().split())
    C[i][j] = c

ans = 0
for P in permutations(range(n)):
    res = 0
    for i in range(len(P) - 1):
        if C[P[i]][P[i + 1]] != -1:
            res += C[P[i]][P[i + 1]]
    ans = max(ans, res)
print(ans)
0