結果

問題 No.90 品物の並び替え
ユーザー pessimist
提出日時 2025-06-19 15:42:12
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 413 bytes
コンパイル時間 430 ms
コンパイル使用メモリ 12,288 KB
実行使用メモリ 10,368 KB
最終ジャッジ日時 2025-06-19 15:42:16
合計ジャッジ時間 2,756 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
read=sys.stdin.buffer.read
readline=sys.stdin.buffer.readline

from itertools import permutations
n,m=map(int,readline().split())
m=map(int,read().split())
mat=[[0 for _ in range(n)] for _ in range(n)]
a,b,c=zip(*zip(m,m,m))
for a, b, c in zip(a,b,c):
  mat[a][b]+=c

ans=0
for perm in permutations(range(n)):
  tans=0
  for x,y in zip(perm,perm[1:]):
    tans+=mat[x][y]
  ans=max(ans,tans)
print(ans)
0