結果

問題 No.90 品物の並び替え
ユーザー shokayamorishokayamori
提出日時 2020-12-07 18:55:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 765 ms / 5,000 ms
コード長 580 bytes
コンパイル時間 142 ms
コンパイル使用メモリ 81,812 KB
実行使用メモリ 99,104 KB
最終ジャッジ日時 2023-10-17 16:37:00
合計ジャッジ時間 2,162 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
53,616 KB
testcase_01 AC 136 ms
77,300 KB
testcase_02 AC 34 ms
53,616 KB
testcase_03 AC 66 ms
70,740 KB
testcase_04 AC 63 ms
72,780 KB
testcase_05 AC 113 ms
77,232 KB
testcase_06 AC 97 ms
77,176 KB
testcase_07 AC 51 ms
66,344 KB
testcase_08 AC 35 ms
53,616 KB
testcase_09 AC 765 ms
99,104 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools

N, M = map(int, input().split())
score_table = []
for i in range(M):
    score_table.append(list(map(int, input().split())))

perms = itertools.permutations(list(range(N)))

total_score_list = []
for perm in perms:
    total_score = 0
    for [back, forth, score] in score_table:
        for elem in perm:
            if elem == forth:
                break
            elif  elem == back:
                total_score += score
                break
            else:
                continue
    total_score_list.append(total_score)

print(max(total_score_list))
0