結果
問題 |
No.788 トラックの移動
|
ユーザー |
|
提出日時 | 2020-06-17 15:57:44 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 996 bytes |
コンパイル時間 | 142 ms |
コンパイル使用メモリ | 82,372 KB |
実行使用メモリ | 84,924 KB |
最終ジャッジ日時 | 2024-07-03 12:15:53 |
合計ジャッジ時間 | 11,574 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 4 WA * 10 |
ソースコード
n,m,l = map(int,input().split()) l -= 1 T = list(map(int,input().split())) from heapq import * def Dijkstra(n,path,start): inf = pow(10,18) d = [inf]*n d[start] = 0 pq = [(0, start)] heapify(pq) while pq: dist, p = heappop(pq) if dist > d[p]:continue for nxt,cost in path[p].items(): if dist + cost >= d[nxt]:continue d[nxt] = dist + cost heappush(pq,(d[nxt],nxt)) return d path = [{} for _ in range(n)] for i in range(m): a,b,c = map(int,input().split()) a -= 1 b -= 1 path[a][b] = c path[b][a] = c ld = Dijkstra(n,path,l) def total(n,path,t,start,ld): d = Dijkstra(n,path,start) res = 0 delta = pow(10,10) for i in range(n): res += 2*d[i]*t[i] if t[i] > 0: delta = min(delta, ld[i] - d[i]) if res == 0:return res else: return res + delta ans = pow(10,10) for i in range(n): ans = min(ans,total(n,path,T,i,ld)) print(ans)