結果
問題 | No.90 品物の並び替え |
ユーザー |
![]() |
提出日時 | 2018-12-23 05:47:50 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 778 bytes |
コンパイル時間 | 130 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 16,000 KB |
最終ジャッジ日時 | 2024-09-25 10:27:35 |
合計ジャッジ時間 | 6,592 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | TLE * 1 -- * 8 |
ソースコード
import collections def calc(order, table): score = 0 it1, it2, sc = 0, 1, 2 for tb in table: if order[tb[it1]] < order[tb[it2]]: score += tb[sc] return score def solve(order, idx, used, score, table): if idx == n: score = calc(order, table) else: for i in range(len(used)): if not used[i]: used[i] = True order[i] = idx score = max(solve(order, idx + 1, used, score, table), score) used[i] = False order[i] = -1 return score n, m = [int(x) for x in input().split()] tb = [] for i in range(m): tb += [[int(x) for x in input().split()]] order = [-1] * n used = [False] * n score = solve(order, 0, used, 0, tb) print(score)