c++ solution | easiest dp solution 
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
```cpp []
// lc
#define vi vector<int>
#define vvii vector<vi>
#define vpii vector<pair<int,int>>
#define pii  pair<int,int>
#define ll long long int
#define vs vector<string>
#define mii map<int, int>
#define umii unordered_map<int, int> 
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define sall(x) sort(x.begin(), x.end());
#define rall(x) sort(x.rbegin(), x.rend())
#define pb push_back 
#define in insert
#define ff first
#define ss second
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define sall(x) sort(x.begin(), x.end());
#define rall(x) sort(x.rbegin(), x.rend())
#define MAX(x) *max_element(x.begin(), x.end())
#define MIN(x) *min_element(x.begin(), x.end())
#define SUM(X) accumulate(X.begin(), X.end(), 0LL)
#define rev(a) reverse(a.begin(), a.end());
const int mod = 1e9 + 7;

class Solution {
public:
    int minCost(int maxTime, vector<vector<int>>& edges, vector<int>& passingFees) {
        int n = passingFees.size();
        vi cost(n,INT_MAX), time(n,INT_MAX);
        vector<vpii> adj(n);
        for(auto it: edges) {
            adj[it[0]].pb({it[1], it[2]});
            adj[it[1]].pb({it[0], it[2]});
        }
        // dp is much easier here
        vvii dp(n+1,vi(maxTime+1,-1));
        auto rec = [&](int node, int time, auto &&self)->int{
             if(node == n-1) return passingFees[node];
             if(dp[node][time] != -1) return dp[node][time];
             
             int ans = 1e9;
             for(auto it: adj[node]){
                int v = it.ff;
                int t = it.ss;
                if(time + t <= maxTime) {
                   ans = min(ans, passingFees[node] + self(v, t+time, self));
                }
             }
             return dp[node][time] = ans;
        };
        int ans = rec(0,0,rec);
        return (ans >= 1e9) ? -1 : ans;
        
       
    }
};
```
['C++']