DP, O(len(edges)*maxTime*log(maxTime)) TC
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```python3 []
class Solution:

    def __init__(self):
        from collections import defaultdict
        self.edges = defaultdict(list)
    
    def minCost(self, maxTime: int, edges: list[list[int]], passingFees: list[int]) -> int:
        import heapq
        n = len(passingFees)
        for u, v, t in edges:
            self.edges[u].append([v, t])
            self.edges[v].append([u, t])
        times = {}
        times[0] = [passingFees[0]] + [10 ** 9] * n
        nextTime = []
        minTime = 0
        while minTime <= maxTime:
            for i in range(n):
                if times[minTime][i] < 10 ** 9:
                    for x, t in self.edges[i]:
                        if minTime + t not in times:
                            times[minTime + t] = [10 ** 9] * n
                            times[minTime + t][x] = times[minTime][i] + passingFees[x]
                            heapq.heappush(nextTime, minTime + t)
                        else:
                            times[minTime + t][x] = min(times[minTime + t][x], times[minTime][i] + passingFees[x])
            minTime = heapq.heappop(nextTime)
        ans = min([times[x][n - 1] for x in times if x <= maxTime])
        return ans if ans < 10 ** 9 else -1
```
['Python3']