結果

問題 No.90 品物の並び替え
ユーザー _matumo__matumo_
提出日時 2019-12-06 16:04:37
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,721 ms / 5,000 ms
コード長 436 bytes
コンパイル時間 204 ms
コンパイル使用メモリ 10,892 KB
実行使用メモリ 8,260 KB
最終ジャッジ日時 2023-08-24 21:56:24
合計ジャッジ時間 3,310 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,076 KB
testcase_01 AC 174 ms
8,124 KB
testcase_02 AC 15 ms
8,260 KB
testcase_03 AC 32 ms
8,260 KB
testcase_04 AC 33 ms
8,228 KB
testcase_05 AC 173 ms
8,164 KB
testcase_06 AC 172 ms
8,148 KB
testcase_07 AC 18 ms
8,260 KB
testcase_08 AC 15 ms
8,184 KB
testcase_09 AC 1,721 ms
8,092 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools
def main():
    N,M=map(int,input().split())
    pa=[[0]*N for _ in range(N)]
    for _ in range(M):
        a,b,c=map(int,input().split())
        pa[a][b]=c

    Max=0
    for p in itertools.permutations(range(N)):
        sum=0
        for i in range(N-1):
            for j in range(i+1,N):
                x,y=p[i],p[j]
                sum+=pa[x][y]
                
        Max=max(Max,sum)
    print(Max)

main()
0