結果
問題 | No.90 品物の並び替え |
ユーザー |
|
提出日時 | 2022-01-21 18:21:23 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 35 ms / 5,000 ms |
コード長 | 530 bytes |
コンパイル時間 | 166 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 10,880 KB |
最終ジャッジ日時 | 2024-11-25 18:10:23 |
合計ジャッジ時間 | 1,149 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 |
ソースコード
from collections import defaultdictN, M = map(int, input().split())G = defaultdict(dict)for _ in range(M):u, v, score = map(int, input().split())G[v][u] = scoredp = [0] * (1 << N)for bit in range(1 << N):for u in range(N):if bit >> u & 1:continuetot = 0for v in range(N):if ~bit >> v & 1:continueif v in G[u]:tot += G[u][v]dp[bit | (1 << u)] = max(dp[bit | (1 << u)], dp[bit] + tot)print(dp[-1])