結果

問題 No.90 品物の並び替え
ユーザー togatogatogatoga
提出日時 2015-09-11 08:45:15
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 266 ms / 5,000 ms
コード長 413 bytes
コンパイル時間 635 ms
コンパイル使用メモリ 77,804 KB
実行使用メモリ 79,184 KB
最終ジャッジ日時 2023-09-26 10:29:28
合計ジャッジ時間 2,491 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
76,628 KB
testcase_01 AC 99 ms
78,820 KB
testcase_02 AC 73 ms
76,388 KB
testcase_03 AC 83 ms
78,960 KB
testcase_04 AC 86 ms
79,144 KB
testcase_05 AC 100 ms
78,988 KB
testcase_06 AC 98 ms
79,184 KB
testcase_07 AC 84 ms
79,068 KB
testcase_08 AC 72 ms
76,384 KB
testcase_09 AC 266 ms
79,020 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools
N,M = map(int, raw_input().split())
scores = [[0 for i in range(N)] for j in range(N)]
for i in range(M):
    a,b,c = map(int, raw_input().split())
    scores[a][b] = c

base = range(0, N)
ans = 0
for perm in itertools.permutations(base):
    tmp = 0
    for i in range(N):
        for j in range(i + 1, N):
            tmp += scores[perm[i]][perm[j]]
    
    ans = max(ans, tmp)
    
print ans
0