結果

問題 No.90 品物の並び替え
ユーザー 百
提出日時 2023-04-13 13:57:17
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 395 bytes
コンパイル時間 245 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 60,032 KB
最終ジャッジ日時 2024-04-17 17:48:31
合計ジャッジ時間 12,637 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

import math
import itertools

N,M=map(int,input().split())
s=[[0,0,0]]+[list(map(int,input().split())) for _ in range(M)]
n=math.factorial(N)
l=list(itertools.permutations(range(N)))
d=[[0 for _ in range(n)] for _ in range(M+1)]

for i in range(1,M+1):
    for j in range(n):
        if list(l[j]).index(s[i][0])<list(l[j]).index(s[i][1]):
            d[i][j]=d[i-1][j]+s[i][2]

print(max(d[M]))
0