結果
問題 | No.90 品物の並び替え |
ユーザー |
![]() |
提出日時 | 2015-09-20 22:47:21 |
言語 | Python2 (2.7.18) |
結果 |
AC
|
実行時間 | 3,078 ms / 5,000 ms |
コード長 | 555 bytes |
コンパイル時間 | 40 ms |
コンパイル使用メモリ | 6,784 KB |
実行使用メモリ | 6,400 KB |
最終ジャッジ日時 | 2024-07-19 08:24:36 |
合計ジャッジ時間 | 4,574 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 |
ソースコード
# -*- coding: utf-8 -*- N, M = map(int, raw_input().split()) l = [] for i in xrange(M): k = map(int, raw_input().split()) l.append(k) def score(m): score = 0 for k in l: if m[k[0]] < m[k[1]]: score += k[2] return score maxs = 0 def dp(l, m): if len(l) == 0: return score(m) mx = 0 for i in xrange(len(l)): froml = list(l) tol = list(m) tol.append(froml.pop(i)) c = dp(froml, tol) mx = max(mx, c) return mx start = [i for i in xrange(N)] print dp(start, [])