結果

問題 No.90 品物の並び替え
ユーザー koyoprokoyopro
提出日時 2015-09-20 22:47:21
言語 Python2
(2.7.18)
結果
AC  
実行時間 3,109 ms / 5,000 ms
コード長 555 bytes
コンパイル時間 606 ms
コンパイル使用メモリ 6,688 KB
実行使用メモリ 6,108 KB
最終ジャッジ日時 2023-09-26 14:07:48
合計ジャッジ時間 5,185 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
5,948 KB
testcase_01 AC 274 ms
5,820 KB
testcase_02 AC 12 ms
5,912 KB
testcase_03 AC 36 ms
6,056 KB
testcase_04 AC 44 ms
5,812 KB
testcase_05 AC 301 ms
6,108 KB
testcase_06 AC 243 ms
6,096 KB
testcase_07 AC 15 ms
5,820 KB
testcase_08 AC 11 ms
5,828 KB
testcase_09 AC 3,109 ms
5,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- 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, [])
0