結果

問題 No.90 品物の並び替え
ユーザー バカらっくバカらっく
提出日時 2019-09-28 04:30:04
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 3,440 ms / 5,000 ms
コード長 790 bytes
コンパイル時間 127 ms
コンパイル使用メモリ 12,128 KB
実行使用メモリ 10,248 KB
最終ジャッジ日時 2023-10-26 02:07:42
合計ジャッジ時間 5,610 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,248 KB
testcase_01 AC 366 ms
10,248 KB
testcase_02 AC 29 ms
10,248 KB
testcase_03 AC 64 ms
10,248 KB
testcase_04 AC 63 ms
10,248 KB
testcase_05 AC 353 ms
10,248 KB
testcase_06 AC 353 ms
10,248 KB
testcase_07 AC 34 ms
10,248 KB
testcase_08 AC 30 ms
10,248 KB
testcase_09 AC 3,440 ms
10,248 KB
権限があれば一括ダウンロードができます

ソースコード

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