結果

問題 No.90 品物の並び替え
ユーザー lloyzlloyz
提出日時 2022-06-13 21:18:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 259 ms / 5,000 ms
コード長 446 bytes
コンパイル時間 582 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 75,588 KB
最終ジャッジ日時 2024-04-08 17:30:40
合計ジャッジ時間 1,511 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
53,460 KB
testcase_01 AC 80 ms
75,568 KB
testcase_02 AC 37 ms
53,460 KB
testcase_03 AC 53 ms
64,452 KB
testcase_04 AC 53 ms
64,448 KB
testcase_05 AC 75 ms
75,588 KB
testcase_06 AC 80 ms
75,568 KB
testcase_07 AC 51 ms
64,460 KB
testcase_08 AC 37 ms
53,460 KB
testcase_09 AC 259 ms
75,568 KB
権限があれば一括ダウンロードができます

ソースコード

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(n - 1):
        pi = P[i]
        for j in range(i + 1, n):
            pj = P[j]
            if C[pi][pj] != -1:
                res += C[pi][pj]
    ans = max(ans, res)
print(ans)
0