C++ Solution | Modified Dijkstra
\nclass Solution {\npublic:\n    int minCost(int maxTime, vector<vector<int>>& edges, vector<int>& passingFees) {\n        \n        int n=passingFees.size();\n
```\nclass Solution {\npublic:\n    int minCost(int maxTime, vector<vector<int>>& edges, vector<int>& passingFees) {\n        \n        int n=passingFees.size();\n        vector<vector<pair<int,int>>>mat(n);\n        vector<int>cost(n,INT_MAX);\n        vector<int>time(n,INT_MAX);\n        for(auto x:edges)\n        {\n            mat[x[0]].push_back({x[1],x[2]});\n            mat[x[1]].push_back({x[0],x[2]});\n        }\n        \n        priority_queue<vector<int>,vector<vector<int>>, greater<vector<int>>>pq;\n        cost[0]=passingFees[0];\n        time[0]=0;\n        pq.push({cost[0],time[0],0});\n        \n        while(!pq.empty())\n        {\n            auto t =pq.top();\n            pq.pop();\n            {\n                for(auto x:mat[t[2]])\n                {\n                    int t_x =x.second;\n                    int y=x.first;\n                    if((cost[y]>t[0]+passingFees[y]) ||(time[y]>t[1]+t_x))\n                    {\n                        if(t[1]+t_x<=maxTime)\n                        {\n                            if(cost[y]>t[0]+passingFees[y])\n                            {\n                                cost[y]=t[0]+passingFees[y];\n                                time[y]=t[1]+t_x;\n                                pq.push({cost[y],time[y],y}); \n                            }\n                            else if(time[y]>t[1]+t_x)\n                            {\n                                time[y]=t[1]+t_x;\n                                pq.push({t[0]+passingFees[y],time[y],y}); \n                            }\n                              \n                        }\n                    }\n                }\n            }\n        }\n        if(time[n-1]>maxTime||cost[n-1]==INT_MAX)\n            return -1;\n        else\n            return cost[n-1];\n        \n    }\n};\n```
['C']