結果
問題 | No.2739 Time is money |
ユーザー |
👑 |
提出日時 | 2024-04-20 13:07:04 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 757 ms / 2,000 ms |
コード長 | 625 bytes |
コンパイル時間 | 284 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 111,084 KB |
最終ジャッジ日時 | 2024-10-12 08:31:54 |
合計ジャッジ時間 | 11,862 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
ソースコード
from heapq import heappop, heappushn, m, x = map(int, input().split())edges = [[] for _ in range(n)]for _ in range(m):u, v, c, t = map(int, input().split())c += t * xu -= 1v -= 1edges[u].append((v, c))edges[v].append((u, c))dist = [1 << 60] * ndist[0] = 0hq = [0]while hq:tmp = heappop(hq)d = tmp // npos = tmp - d * nif dist[pos] < d:continuefor to, cost in edges[pos]:if dist[to] > d + cost:dist[to] = d + costheappush(hq, to + n * dist[to])ans = (dist[-1] + x - 1) // x if dist[-1] != 1 << 60 else -1print(ans)