結果

問題 No.90 品物の並び替え
ユーザー 141sksk141sksk
提出日時 2019-08-31 20:20:48
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,523 ms / 5,000 ms
コード長 520 bytes
コンパイル時間 961 ms
コンパイル使用メモリ 10,844 KB
実行使用メモリ 8,264 KB
最終ジャッジ日時 2023-08-16 16:13:03
合計ジャッジ時間 3,500 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
8,196 KB
testcase_01 AC 155 ms
8,144 KB
testcase_02 AC 16 ms
8,140 KB
testcase_03 AC 30 ms
8,136 KB
testcase_04 AC 30 ms
8,264 KB
testcase_05 AC 156 ms
8,172 KB
testcase_06 AC 156 ms
8,264 KB
testcase_07 AC 18 ms
8,116 KB
testcase_08 AC 16 ms
8,116 KB
testcase_09 AC 1,523 ms
8,148 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools

def main():

    n, m = map(int, input().split())
    myList = [[0] * n for _ in range(n)]
    for _ in range(m):
        i1, i2, score = map(int, input().split())
        myList[i1][i2] = score

    mx = 0
    for cmb in itertools.permutations([i for i in range(n)]):
        total = 0
        for j in range(n - 1):
            for k in range(j + 1, n):
                total += myList[cmb[j]][cmb[k]]
        if total > mx:
            mx = total
    print(mx)

if __name__ == "__main__":
    main()
0