結果

問題 No.3011 品物の並び替え (Extra)
ユーザー convexineqconvexineq
提出日時 2020-12-17 19:20:24
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 603 bytes
コンパイル時間 850 ms
コンパイル使用メモリ 81,764 KB
実行使用メモリ 77,148 KB
最終ジャッジ日時 2023-10-21 07:05:26
合計ジャッジ時間 1,775 ms
ジャッジサーバーID
(参考情報)
judge9 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 112 ms
77,148 KB
testcase_05 AC 89 ms
76,824 KB
testcase_06 AC 87 ms
76,668 KB
testcase_07 AC 98 ms
76,908 KB
testcase_08 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int,input().split())
d = [[0]*n for _ in range(n)]
for _ in range(m):
    x,y,c = map(int,input().split())
    d[x][y] += c
    
from random import shuffle
r = list(range(n))
v = 0
for _ in range(1000):
    shuffle(r)
    while True:
        for i in range(n-1):
            if d[r[i]][r[i+1]] < d[r[i+1]][r[i]]:
                r[i],r[i+1] = r[i+1],r[i]                
                break
        else:
            break
    
    s = 0
    for i in range(n):
        for j in range(i+1,n):
            s += d[r[i]][r[j]]
    if v < s:
        v = s
        ans = r[:]

print(v)
print(*ans)
0