結果
問題 |
No.788 トラックの移動
|
ユーザー |
![]() |
提出日時 | 2024-05-15 03:26:24 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 944 bytes |
コンパイル時間 | 295 ms |
コンパイル使用メモリ | 82,476 KB |
実行使用メモリ | 112,020 KB |
最終ジャッジ日時 | 2024-12-20 10:08:35 |
合計ジャッジ時間 | 12,886 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 8 WA * 2 TLE * 4 |
ソースコード
import sys input = sys.stdin.readline from heapq import heappop,heappush N,M,L=map(int,input().split()) T=list(map(int,input().split())) L-=1 E=[[] for i in range(N)] for i in range(M): a,b,c=map(int,input().split()) a-=1 b-=1 E[a].append((b,c)) E[b].append((a,c)) D=[[1<<60]*N for i in range(N)] for i in range(N): D[i][i]=0 Q=[(0,i)] while Q: #print(Q) dis,ind=heappop(Q) #print(D[i][ind]) if D[i][ind]!=dis: continue for to,length in E[ind]: if D[i][to]>dis+length: D[i][to]=dis+length heappush(Q,(D[i][to],to)) ANS=1<<63 for i in range(N): score=0 for j in range(N): score+=T[j]*D[i][j]*2 for j in range(N): if T[j]>0: score+=D[L][j]-D[i][j] ANS=min(ANS,score) score-=D[L][j]-D[i][j] print(ANS)