結果

問題 No.3011 品物の並び替え (Extra)
ユーザー convexineqconvexineq
提出日時 2020-12-17 19:27:37
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 486 bytes
コンパイル時間 151 ms
コンパイル使用メモリ 82,092 KB
実行使用メモリ 77,268 KB
最終ジャッジ日時 2024-09-21 08:13:43
合計ジャッジ時間 8,148 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 1,044 ms
77,164 KB
testcase_05 AC 460 ms
76,368 KB
testcase_06 AC 418 ms
76,620 KB
testcase_07 AC 1,078 ms
76,496 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

r = list(range(n))
s = 0
for i in range(n):
    for j in range(i+1,n):
        s += d[r[i]][r[j]]
v = s
ans = r[:]

from random import randrange
for _ in range(10000000):
    i = randrange(n-1)
    s += d[r[i+1]][r[i]] - d[r[i]][r[i+1]]
    r[i],r[i+1] = r[i+1],r[i]                
    if v < s:
        v = s
        ans = r[:]

print(v)
print(*ans)
0