結果
| 問題 |
No.357 品物の並び替え (Middle)
|
| コンテスト | |
| ユーザー |
みあえ
|
| 提出日時 | 2024-04-01 01:14:35 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 769 bytes |
| コンパイル時間 | 319 ms |
| コンパイル使用メモリ | 82,356 KB |
| 実行使用メモリ | 76,964 KB |
| 最終ジャッジ日時 | 2024-09-30 21:33:24 |
| 合計ジャッジ時間 | 2,784 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 2 WA * 16 |
ソースコード
from collections import defaultdict
from itertools import combinations
def solve(N, M, items2score):
dp = [-float("inf")] * (1 << N)
dp[0] = 0
for V in range(1 << N):
for i in range(N):
for j in range(N):
if i == j:
continue
if not ((V >> i) & 1) or not ((V >> j) & 1):
VV = V | (1 << i) | (1 << j)
dp[VV] = max(dp[VV], dp[V] + items2score[(i, j)])
return dp[-1]
def main():
N, M = map(int, input().split())
items2socre = defaultdict(int)
for _ in range(M):
i, j, s = map(int, input().split())
items2socre[(i, j)] = s
ans = solve(N, M, items2socre)
print(ans)
if __name__ == "__main__":
main()
みあえ