結果
問題 |
No.2387 Yokan Factory
|
ユーザー |
|
提出日時 | 2023-07-21 23:44:09 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 792 bytes |
コンパイル時間 | 140 ms |
コンパイル使用メモリ | 82,184 KB |
実行使用メモリ | 121,860 KB |
最終ジャッジ日時 | 2024-09-22 01:11:01 |
合計ジャッジ時間 | 7,764 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 12 TLE * 1 -- * 22 |
ソースコード
from heapq import heappush, heappop INF = 10 ** 20 def dijkstra(s, N): # (始点, ノード数) dist = [-1 for _ in range(N)] hq = [(0, INF, s)] dist[s] = INF while hq: d, w, v = heappop(hq) # ノードを pop する for to, cost, width in G[v]: # ノード v に隣接しているノードに対して nw = min(w, width) nd = d+cost if nd>X: continue if dist[to] < nw : dist[to] = nw heappush(hq, (nd, nw, to)) return dist N, M, X = map(int, input().split()) G = [[] for _ in range(N)] for _ in range(M): u, v, a, b = map(int, input().split()) u-=1 v-=1 G[u].append((v, a, b)) G[v].append((u, a, b)) ans = dijkstra(0, N) print(ans[-1])