結果
問題 | No.2739 Time is money |
ユーザー |
|
提出日時 | 2024-05-01 20:19:08 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 897 ms / 2,000 ms |
コード長 | 646 bytes |
コンパイル時間 | 509 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 131,372 KB |
最終ジャッジ日時 | 2024-11-22 02:37:55 |
合計ジャッジ時間 | 14,107 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
ソースコード
from heapq import heappop, heappushfrom collections import defaultdictn, m, x = map(int, input().split())G = defaultdict(list)for _ in range(m):u, v, c, t = map(int, input().split())u -= 1v -= 1G[u].append((v, c + t * x))G[v].append((u, c + t * x))INF = 10**18DP = [INF for _ in range(n)]DP[0] = 0H = [(0, 0)]while H:cc, cp = heappop(H)if cc > DP[cp]:continuefor np, dc in G[cp]:nc = cc + dcif nc >= DP[np]:continueDP[np] = ncheappush(H, (nc, np))ans = DP[n - 1]if ans == INF:ans = -1else:ans = (ans + x - 1) // xprint(ans)