結果
問題 | No.2739 Time is money |
ユーザー |
|
提出日時 | 2024-09-29 19:07:23 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,036 ms / 2,000 ms |
コード長 | 691 bytes |
コンパイル時間 | 1,273 ms |
コンパイル使用メモリ | 82,400 KB |
実行使用メモリ | 130,616 KB |
最終ジャッジ日時 | 2024-09-29 19:07:38 |
合計ジャッジ時間 | 14,491 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
ソースコード
N,M,X = map(int, input().split())edge = [[] for i in range(N)]for i in range(M):u,v,c,t = map(int, input().split())u-=1;v-=1edge[u].append((v,(t+c/X)*10**12))edge[v].append((u,(t+c/X)*10**12))from heapq import *INF = 10**24def dijkstra(N, edge, s):dist = [INF] * Nque = [(0, s)]dist[s] = 0while que:c, v = heappop(que)if dist[v] < c:continuefor t, cost in edge[v]:if dist[v] + cost < dist[t]:dist[t] = dist[v] + costheappush(que, (dist[t], t))return distimport mathd = dijkstra(N,edge,0)ans = d[-1]print(math.ceil(ans/10**12) if ans != INF else -1)