結果
| 問題 | No.90 品物の並び替え |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-01-21 18:21:23 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
AC
|
| 実行時間 | 101 ms / 5,000 ms |
| コード長 | 530 bytes |
| 記録 | |
| コンパイル時間 | 567 ms |
| コンパイル使用メモリ | 20,828 KB |
| 実行使用メモリ | 15,232 KB |
| 最終ジャッジ日時 | 2026-05-20 08:13:30 |
| 合計ジャッジ時間 | 2,873 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 9 |
ソースコード
from collections import defaultdict
N, M = map(int, input().split())
G = defaultdict(dict)
for _ in range(M):
u, v, score = map(int, input().split())
G[v][u] = score
dp = [0] * (1 << N)
for bit in range(1 << N):
for u in range(N):
if bit >> u & 1:
continue
tot = 0
for v in range(N):
if ~bit >> v & 1:
continue
if v in G[u]:
tot += G[u][v]
dp[bit | (1 << u)] = max(dp[bit | (1 << u)], dp[bit] + tot)
print(dp[-1])