結果
| 問題 | 
                            No.90 品物の並び替え
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2017-08-09 22:45:56 | 
| 言語 | Python3  (3.13.1 + numpy 2.2.1 + scipy 1.14.1)  | 
                    
| 結果 | 
                             
                                TLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 731 bytes | 
| コンパイル時間 | 347 ms | 
| コンパイル使用メモリ | 12,288 KB | 
| 実行使用メモリ | 60,192 KB | 
| 最終ジャッジ日時 | 2024-10-12 04:08:18 | 
| 合計ジャッジ時間 | 10,511 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 8 TLE * 1 | 
ソースコード
# -*- 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)