結果

問題 No.90 品物の並び替え
ユーザー caleicalei
提出日時 2019-12-31 11:42:17
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 376 bytes
コンパイル時間 72 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 60,572 KB
最終ジャッジ日時 2024-04-29 08:07:49
合計ジャッジ時間 8,565 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
10,880 KB
testcase_01 AC 528 ms
15,616 KB
testcase_02 AC 24 ms
10,880 KB
testcase_03 AC 58 ms
11,136 KB
testcase_04 AC 84 ms
11,264 KB
testcase_05 AC 630 ms
15,616 KB
testcase_06 AC 437 ms
15,488 KB
testcase_07 AC 32 ms
10,752 KB
testcase_08 AC 24 ms
10,752 KB
testcase_09 TLE -
権限があれば一括ダウンロードができます

ソースコード

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