結果

問題 No.90 品物の並び替え
ユーザー maatanbetamaatanbeta
提出日時 2017-04-27 15:37:02
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,617 ms / 5,000 ms
コード長 812 bytes
コンパイル時間 166 ms
コンパイル使用メモリ 10,820 KB
実行使用メモリ 8,556 KB
最終ジャッジ日時 2023-10-11 16:04:00
合計ジャッジ時間 3,355 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
8,544 KB
testcase_01 AC 197 ms
8,404 KB
testcase_02 AC 19 ms
8,520 KB
testcase_03 AC 41 ms
8,556 KB
testcase_04 AC 41 ms
8,392 KB
testcase_05 AC 200 ms
8,548 KB
testcase_06 AC 197 ms
8,484 KB
testcase_07 AC 22 ms
8,412 KB
testcase_08 AC 18 ms
8,396 KB
testcase_09 AC 1,617 ms
8,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from copy import deepcopy

N, M = map(int, input().split())
item1 = [0] * M
item2 = [0] * M
score = [0] * M
sheat = []
max_score = 0

for p in range(N):
    l = []
    for q in range(N):
        l.append(0)
    sheat.append(l)

for i in range(M):
    item1[i], item2[i], score[i] = map(int, input().split())
    sheat[item1[i]][item2[i]] = score[i]


def dp(check):
    if len(check) == 0:
        return 0
    elif len(check) == 1:
        return 0
    else:
        tempmax = 0
        for i in check:
            temp = deepcopy(check)
            temp.remove(i)
            temp2 = 0
            for p in temp:
                temp2 += sheat[p][i]
            temp2 += dp(temp)
            if tempmax < temp2:
                tempmax = temp2
        return tempmax


l = [i for i in range(N)]

print(dp(l))
0