input: from typing import List
  from heapq import heappop, heappush
  
  def find_min_time(n: int, edges: List[List[int]], disappear: List[int]) -> List[int]:
      """
      You are given an undirected graph with n nodes. Provided is a 2D list named edges, where edges[i] = [ui, vi, lengthi] represents an edge between nodes ui and vi, with a traversal time of lengthi units.
  
      Additionally, another list named disappear indicates the time at which each corresponding node becomes inaccessible.
  
      The graph may be disconnected and may have duplicate edges.
  
      Return a list where each element answer[i] denotes the minimum time needed to reach node i from node 0. If node i cannot be reached from node 0, return -1 for that node.
  
      Examples:
      >>> find_min_time(3, [[0,1,2],[1,2,1],[0,2,4]], [1,1,5])
      [0,-1,4]
      >>> find_min_time(3, [[0,1,2],[1,2,1],[0,2,4]], [1,3,5])
      [0,2,3]
      >>> find_min_time(2, [[0,1,1]], [1,1])
      [0,-1]
  
      Constraints:
      1 <= n <= 5 * 10^4
      0 <= edges.length <= 10^5
      edges[i] == [ui, vi, lengthi]
      0 <= ui, vi <= n - 1
      1 <= lengthi <= 10^5
      disappear.length == n
      1 <= disappear[i] <= 10^5
      """
output:     import heapq
  
      # Write adjacency list for the graph
      graph = [[] for _ in range(n)]
      for u, v, length in edges:
          graph[u].append((v, length))
          graph[v].append((u, length))
  
      # Initialize distances as infinity
      dist = [float('inf')] * n
      dist[0] = 0
  
      # Priority queue to store (distance, node)
      pq = [(0, 0)]
  
      while pq:
          current_dist, node = heapq.heappop(pq)
          
          if current_dist > disappear[node]:
              continue
          
          for neighbor, length in graph[node]:
              new_dist = current_dist + length
              if disappear[neighbor] >= new_dist and new_dist < dist[neighbor]:
                  dist[neighbor] = new_dist
                  heapq.heappush(pq, (new_dist, neighbor))
  
      # Prepare the answer list
      answer = []
      for i in range(n):
          if dist[i] == float('inf') or dist[i] > disappear[i]:
              answer.append(-1)
          else:
              answer.append(dist[i])
  
      return answer