結果
| 問題 | No.90 品物の並び替え |
| コンテスト | |
| ユーザー |
Tawara
|
| 提出日時 | 2015-09-15 00:20:20 |
| 言語 | PyPy2 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 106 ms / 5,000 ms |
| コード長 | 406 bytes |
| 記録 | |
| コンパイル時間 | 139 ms |
| コンパイル使用メモリ | 77,724 KB |
| 最終ジャッジ日時 | 2025-12-03 16:56:34 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 9 |
ソースコード
N,M=map(int,raw_input().split())
S = [map(int,raw_input().split()) for i in xrange(M)]
dp = {0:0}
for i in xrange(N):
tmp_dp = dict()
for k,v in dp.iteritems():
for j in xrange(N):
bit = 1<<j
if k&bit: continue
nk = k|bit
tmp_v = v + sum(s[2] for s in S if s[0]==j and ((1<<s[1])&nk)==0)
if not (nk in tmp_dp and tmp_dp[nk] >= tmp_v):
tmp_dp[nk] = tmp_v
dp = tmp_dp
print dp[2**N-1]
Tawara