結果

問題 No.90 品物の並び替え
ユーザー sdadssdads
提出日時 2019-02-01 16:17:05
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 809 bytes
コンパイル時間 272 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 64,800 KB
最終ジャッジ日時 2024-05-02 01:51:37
合計ジャッジ時間 15,871 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
10,752 KB
testcase_01 AC 2,871 ms
17,152 KB
testcase_02 AC 26 ms
10,752 KB
testcase_03 AC 173 ms
11,520 KB
testcase_04 AC 284 ms
11,392 KB
testcase_05 AC 3,274 ms
17,152 KB
testcase_06 AC 2,196 ms
17,152 KB
testcase_07 AC 52 ms
10,880 KB
testcase_08 AC 26 ms
10,752 KB
testcase_09 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools

item1 = []
item2 = []

N, M = list(map(int, input().split()))

score_book = [[0 for i in range(N)] for j in range(N)]

for n in range(M):
    i, j, k = list(map(int, input().split()))
    item1.append(i)
    item2.append(j)
    score_book[item1[n]][item2[n]] = k

#全てのパターンを網羅する。
combi = list(itertools.permutations([i for i in range(N)], N))

#全通りのスコアを入れる配列を作る
score_table = [0 for i in range(len(combi))]

for i in range(len(combi)): 
    for j in range(N - 1):
        for m in range(M):
            if combi[i][j] == item1[m]:
                for k in range(j + 1, N):
                    if combi[i][k] == item2[m]:
                        score_table[i] = score_table[i] + score_book[item1[m]][item2[m]]

print(max(score_table))
0