結果
問題 | No.2739 Time is money |
ユーザー | tassei903 |
提出日時 | 2024-04-17 03:19:55 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 684 bytes |
コンパイル時間 | 156 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 131,448 KB |
最終ジャッジ日時 | 2024-04-17 03:20:12 |
合計ジャッジ時間 | 12,252 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 33 ms
53,120 KB |
testcase_01 | AC | 34 ms
52,992 KB |
testcase_02 | AC | 256 ms
105,176 KB |
testcase_03 | AC | 754 ms
119,104 KB |
testcase_04 | AC | 237 ms
102,144 KB |
testcase_05 | AC | 520 ms
107,616 KB |
testcase_06 | AC | 617 ms
115,396 KB |
testcase_07 | AC | 837 ms
130,204 KB |
testcase_08 | AC | 850 ms
131,144 KB |
testcase_09 | AC | 915 ms
130,820 KB |
testcase_10 | AC | 451 ms
122,496 KB |
testcase_11 | AC | 842 ms
131,448 KB |
testcase_12 | AC | 427 ms
126,388 KB |
testcase_13 | AC | 395 ms
126,396 KB |
testcase_14 | WA | - |
testcase_15 | AC | 435 ms
127,800 KB |
testcase_16 | AC | 479 ms
121,760 KB |
testcase_17 | WA | - |
testcase_18 | WA | - |
ソースコード
from heapq import * INF = 10**18 def dijkstra(g, s, n): dist = [INF]*n hq = [(0, s)] dist[s] = 0 while hq: d, v = heappop(hq) if dist[v]!=d: continue for to, c in g[v]: if dist[v] + c < dist[to]: dist[to] = dist[v] + c heappush(hq, (dist[to], to)) return dist from math import ceil n, m, x = list(map(int, input().split())) g = [[] for _ in range(n)] for i in range(m): u,v,c,t = list(map(int, input().split())) u -= 1 v -= 1 g[u].append((v,t+c/x)) g[v].append((u,t+c/x)) dist = dijkstra(g, 0, n) if dist[-1] == INF: print(-1) else: print(ceil(dist[-1]))