結果
| 問題 |
No.357 品物の並び替え (Middle)
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2025-01-01 03:39:09 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 76 ms / 5,000 ms |
| コード長 | 472 bytes |
| コンパイル時間 | 336 ms |
| コンパイル使用メモリ | 82,432 KB |
| 実行使用メモリ | 69,720 KB |
| 最終ジャッジ日時 | 2025-01-01 03:39:12 |
| 合計ジャッジ時間 | 2,616 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 |
ソースコード
import sys
input = sys.stdin.readline
N,M=map(int,input().split())
L=[[] for i in range(N)]
for i in range(M):
x,y,score=map(int,input().split())
L[y].append((x,score))
DP=[0]*(1<<N)
for i in range(1<<N):
now=DP[i]
for j in range(N):
if i & (1<<j) != 0:
continue
plus=0
for to,score in L[j]:
if i & (1<<to)!=0:
plus+=score
DP[i|(1<<j)]=max(DP[i|(1<<j)],now+plus)
print(max(DP))
titia