結果

問題 No.90 品物の並び替え
ユーザー caleicalei
提出日時 2019-12-31 11:45:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 496 ms / 5,000 ms
コード長 376 bytes
コンパイル時間 766 ms
コンパイル使用メモリ 82,308 KB
実行使用メモリ 130,616 KB
最終ジャッジ日時 2024-04-29 08:12:56
合計ジャッジ時間 2,364 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
51,968 KB
testcase_01 AC 83 ms
82,304 KB
testcase_02 AC 34 ms
52,480 KB
testcase_03 AC 42 ms
64,000 KB
testcase_04 AC 45 ms
63,872 KB
testcase_05 AC 91 ms
82,476 KB
testcase_06 AC 77 ms
82,432 KB
testcase_07 AC 44 ms
62,592 KB
testcase_08 AC 33 ms
52,096 KB
testcase_09 AC 496 ms
130,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 2019/12/31

from itertools import permutations

n,m=map(int,input().split())
items=[tuple(map(int,input().split())) for _ in range(m)]
ps=list(permutations(range(n),n))

ans=0
for p in ps:
    cnt=0
    pp=[None]*n
    for i in range(n):
        pp[p[i]]=i

    for item in items:
        u,v,c=item
        if pp[u]<pp[v]:
            cnt+=c
    ans=max(ans,cnt)
print(ans)
0