結果

問題 No.90 品物の並び替え
ユーザー sdadssdads
提出日時 2019-02-01 10:25:12
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 828 bytes
コンパイル時間 77 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 17,280 KB
最終ジャッジ日時 2024-05-01 12:06:22
合計ジャッジ時間 17,588 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
16,128 KB
testcase_01 AC 3,484 ms
17,280 KB
testcase_02 AC 32 ms
10,880 KB
testcase_03 AC 198 ms
11,520 KB
testcase_04 AC 327 ms
11,392 KB
testcase_05 AC 3,839 ms
17,280 KB
testcase_06 AC 2,601 ms
17,152 KB
testcase_07 AC 57 ms
10,880 KB
testcase_08 AC 30 ms
10,880 KB
testcase_09 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools

item1 = []
item2 = []
score = []

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

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

combi = list(itertools.permutations([i for i in range(N)], N))

#すべてのスコアを2次元のリストに入れる
score_book = [[0 for i in range(N)] for j in range(N)]
score_table = [0 for i in range(len(combi))]

for i in range(M):
    score_book[item1[i]][item2[i]] = score[i]

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, N):
                    if combi[i][k] == item2[m]:
                        score_table[i] = score_table[i] + score_book[item1[m]][item2[m]]


print(max(score_table))
0