結果

問題 No.90 品物の並び替え
ユーザー phtmscg
提出日時 2019-03-29 19:24:19
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 3,997 ms / 5,000 ms
コード長 518 bytes
コンパイル時間 114 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 24,832 KB
最終ジャッジ日時 2024-11-07 01:23:04
合計ジャッジ時間 6,021 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M = map(int,input().split())
items = [list(map(int,input().split())) for _ in range(M)]
ss = []

def change(n,*args):
    b = list(args)
    c = list(args)
    if n < N:
        for i in range(N):
            if b[n] == -1 and i not in b:
                c[n] = i
                change(n+1,*c)
    else:
        score = 0
        for j in range(M):
            if b[items[j][0]] < b[items[j][1]]:
                score += items[j][2]
        global ss
        ss.append(score)
a = [-1]*N
change(0,*a)
print(max(ss))
0