結果

問題 No.90 品物の並び替え
ユーザー _kyou_kyou
提出日時 2024-08-13 01:37:36
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 646 bytes
コンパイル時間 468 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 65,464 KB
最終ジャッジ日時 2024-08-13 01:37:50
合計ジャッジ時間 13,588 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 8 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools

N, M = map(int, input().split())
item1 = [0]*M
item2 = [0]*M
score = [0]*M
all_pattern = list(itertools.permutations(range(N))) # 順列
result = [0] * len(all_pattern)

for i in range(M):
    item1[i], item2[i], score[i] = map(int, input().split())

for i, pattern in enumerate(all_pattern):
    for k in range(M):
        sts = False
        for item in pattern:
            if item == item2[k] and not sts:
                break
            elif item == item1[k] and not sts:
                sts = True
            elif item == item2[k] and sts:
                result[i] += score[k]
                break

print(max(result))
0