Remaining time in node state
\nclass Solution:\n    def minCost(self, maxTime: int, edges: List[List[int]], passingFees: List[int]) -> int:\n        n = len(passingFees)\n        graph = [[
```\nclass Solution:\n    def minCost(self, maxTime: int, edges: List[List[int]], passingFees: List[int]) -> int:\n        n = len(passingFees)\n        graph = [[] for _ in range(n)]\n        for u, v, w in edges:\n            graph[u].append((v, w))\n            graph[v].append((u, w))\n        dist = defaultdict(lambda: float(\'inf\'))\n        dist[(0, maxTime)] = passingFees[0]\n        heap = [(passingFees[0], 0, maxTime)]\n        while heap:\n            cost, i, rem = heapq.heappop(heap)\n            if i == n - 1:\n                return cost\n            for j, w in graph[i]:\n                if w <= rem:\n                    if dist[(j, rem - w)] > cost + passingFees[j]:\n                        dist[(j, rem - w)] = cost + passingFees[j]\n                        heapq.heappush(heap, (cost + passingFees[j], j, rem - w))\n        return -1\n```
['Python']