結果

問題 No.90 品物の並び替え
ユーザー magurogumamaguroguma
提出日時 2017-08-09 22:45:56
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 731 bytes
コンパイル時間 115 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 59,264 KB
最終ジャッジ日時 2024-04-20 08:44:40
合計ジャッジ時間 10,449 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,752 KB
testcase_01 AC 1,110 ms
15,488 KB
testcase_02 AC 30 ms
10,880 KB
testcase_03 AC 91 ms
11,264 KB
testcase_04 AC 144 ms
11,264 KB
testcase_05 AC 1,279 ms
15,488 KB
testcase_06 AC 843 ms
15,616 KB
testcase_07 AC 42 ms
10,624 KB
testcase_08 AC 31 ms
10,752 KB
testcase_09 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-

import itertools as iter

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

# 全通りの品物列を作成
items = []
for i in range(N):
    items.append(i)
sequences = list(iter.permutations(items))

# すべての品物列についてスコアを算出し,最大値を記録する
max_score = -1
for seq in sequences:
    seq_score = 0
    for check in item_score:
        item_1 = check[0]
        item_2 = check[1]
        score = check[2]
        pos_1 = seq.index(item_1)
        pos_2 = seq.index(item_2)
        if pos_1 < pos_2:
            seq_score += score
    max_score = max(max_score, seq_score)

print(max_score)
0