結果

問題 No.3011 品物の並び替え (Extra)
ユーザー convexineqconvexineq
提出日時 2020-12-17 19:27:37
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 486 bytes
コンパイル時間 201 ms
コンパイル使用メモリ 81,800 KB
実行使用メモリ 76,880 KB
最終ジャッジ日時 2023-10-21 07:05:38
合計ジャッジ時間 8,224 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 1,023 ms
76,880 KB
testcase_05 WA -
testcase_06 AC 425 ms
76,224 KB
testcase_07 AC 1,074 ms
76,348 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