Bellman Ford + Python3
\nclass Solution:\n    def minCost(self, maxTime: int, edges: List[List[int]], passingFees: List[int]) -> int:\n        n = len(passingFees)\n        f = [[floa
```\nclass Solution:\n    def minCost(self, maxTime: int, edges: List[List[int]], passingFees: List[int]) -> int:\n        n = len(passingFees)\n        f = [[float("inf")] * n for _ in range(maxTime + 1)]\n        f[0][0] = passingFees[0]\n        for t in range(1, maxTime + 1):\n            for i, j, cost in edges:\n                if cost <= t:\n                    f[t][i] = min(f[t][i], f[t - cost][j] + passingFees[i])\n                    f[t][j] = min(f[t][j], f[t - cost][i] + passingFees[j])\n        ans = min(f[t][n - 1] for t in range(1, maxTime + 1))\n        return -1 if ans == float("inf") else ans\n```
[]