結果
問題 |
No.90 品物の並び替え
|
ユーザー |
|
提出日時 | 2021-06-28 21:18:26 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 38 ms / 5,000 ms |
コード長 | 532 bytes |
コンパイル時間 | 234 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 11,008 KB |
最終ジャッジ日時 | 2024-06-25 15:55:43 |
合計ジャッジ時間 | 1,226 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 |
ソースコード
n, m = [int(s) for s in input().split()] table = [[0 for _ in range(n)] for _ in range(n)] for i in range(m): item1, item2, score = map(int, input().split()) table[item1][item2] = score dp = [0] * (1 << n) for x in range(0, 1 << n): for i in range(n): if x & (1 << i): continue score = dp[x] for j in range(n): if x & (1 << j): score += table[j][i] v = x | (1 << i) if dp[v] < score: dp[v] = score print(dp[(1 << n) - 1])