結果

問題 No.90 品物の並び替え
ユーザー バカらっく
提出日時 2019-09-28 04:30:04
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 3,210 ms / 5,000 ms
コード長 790 bytes
コンパイル時間 152 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-09-25 10:12:26
合計ジャッジ時間 5,127 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

map = {}

for i in range(n):
    map[i] = {}
    for j in range(n):
        map[i][j] = 0

for i in range(m):
    (item1, item2, score) = [int(i) for i in input().rstrip().split(" ")]
    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):
        for j in range(i + 1, len(items)):
            total += map[items[i]][items[j]]
    return total


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