結果
| 問題 | No.90 品物の並び替え |
| コンテスト | |
| ユーザー |
htkb
|
| 提出日時 | 2019-02-11 16:31:56 |
| 言語 | Python3 (3.14.7 + numpy 2.5.2 + scipy 1.18.0) |
| 結果 |
AC
|
| 実行時間 | 96 ms / 5,000 ms |
| + 461µs | |
| コード長 | 545 bytes |
| 記録 | |
| コンパイル時間 | 293 ms |
| コンパイル使用メモリ | 21,540 KB |
| 実行使用メモリ | 15,868 KB |
| 最終ジャッジ日時 | 2026-08-17 03:26:08 |
| 合計ジャッジ時間 | 2,404 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 9 |
ソースコード
N, M = map(int, input().split())
score = [[0]*N for _ in [0]*N]
for a, b, c in (map(int, input().split()) for _ in [0]*M):
score[a][b] = c
dp = [0]*(2**N)
for bitset in range(2**N):
current_score = dp[bitset]
bit_1_list = [i for i in range(N) if bitset & 2**i]
for bit_0 in range(N):
if 2**bit_0 & bitset:
continue
new_score = current_score + sum(score[bit_1][bit_0] for bit_1 in bit_1_list)
if new_score > dp[bitset | 2**bit_0]:
dp[bitset | 2**bit_0] = new_score
print(dp[-1])
htkb