結果
問題 | No.357 品物の並び替え (Middle) |
ユーザー |
|
提出日時 | 2021-09-13 20:48:03 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 80 ms / 5,000 ms |
コード長 | 416 bytes |
コンパイル時間 | 523 ms |
コンパイル使用メモリ | 82,140 KB |
実行使用メモリ | 69,760 KB |
最終ジャッジ日時 | 2024-06-25 21:46:48 |
合計ジャッジ時間 | 2,563 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 |
ソースコード
N,M=map(int,input().split())mat=[[0]*15 for i in range(15)]for i in range(M):u,v,s=map(int,input().split())mat[u][v]=sdp=[0]*(1<<N)for bit in range(1<<N):for i in range(N):if bit>>i&1 :continueres=0for j in range(N):if bit>>j&1:res+=mat[j][i]dp[bit|(1<<i)]=max(dp[bit|(1<<i)],dp[bit]+res)print(dp[(1<<N)-1])