結果

問題 No.90 品物の並び替え
ユーザー バカらっくバカらっく
提出日時 2019-09-28 04:24:22
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 902 bytes
コンパイル時間 92 ms
コンパイル使用メモリ 11,980 KB
実行使用メモリ 10,100 KB
最終ジャッジ日時 2023-10-26 02:01:39
合計ジャッジ時間 7,890 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,100 KB
testcase_01 AC 481 ms
10,100 KB
testcase_02 AC 29 ms
10,100 KB
testcase_03 AC 78 ms
10,100 KB
testcase_04 AC 77 ms
10,100 KB
testcase_05 AC 499 ms
10,100 KB
testcase_06 AC 468 ms
10,100 KB
testcase_07 AC 35 ms
10,100 KB
testcase_08 AC 29 ms
10,100 KB
testcase_09 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding:utf-8 -*-

(n, m) = [int(i) for i in input().rstrip().split(" ")]

map = {}

for i in range(m):
    (item1, item2, score) = [int(i) for i in input().rstrip().split(" ")]
    if item1 not in map.keys():
        map[item1] = {}
    map[item1][item2] = score


def get_ans(*items):
    if len(items) >= n:
        return calc(items)
    total_score = 0
    for i in range(0, n):
        if i in items:
            continue
        ret = get_ans(*items, i)
        total_score = max(ret, total_score)
    return total_score


def calc(items):
    total = 0
    for i in range(len(items) - 1):
        if items[i] not in map.keys():
            continue
        for j in range(i + 1, len(items)):
            if items[j] not in map[items[i]].keys():
                continue
            total += map[items[i]][items[j]]
    return total


ans = max([get_ans(i) for i in range(0, n)])
print(ans)
0