C++ Dijkstra's
\n# Complexity\n- Time complexity:\n Add your time complexity here, e.g. O(n) \nO((E+V)log(V))\n\n- Space complexity:\n Add your space complexity here, e.g. O(n
\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO((E+V)log(V))\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(V) where V is the number of vertices.\n\n# Code\n```\nclass Solution {\npublic:\n    int minCost(int maxTime, vector<vector<int>>& edges, vector<int>& passingFees) {\n        int n=passingFees.size();\n        vector<vector<array<int,2>>> graph(n+1);\n        for(auto e:edges){\n            int x=e[0],y=e[1],cost=e[2];\n            graph[x].push_back({y,cost});graph[y].push_back({x,cost});\n        }\n\n        priority_queue<array<int,3>,vector<array<int,3>>> pq;\n\n        pq.push({-passingFees[0],0,0});\n\n        vector<int> minimumTimeVisited(n+1,INT_MAX);\n        while(pq.size()){\n            auto [cost,node,time]=pq.top();pq.pop();\n            if(minimumTimeVisited[node]<=time) continue;\n            minimumTimeVisited[node]=time;\n\n            if(node==n-1 and time<=maxTime) return -cost;\n\n            for(auto [ne,w]:graph[node]){\n                pq.push({-(-cost+passingFees[ne]),ne,time+w});\n            }\n        }\n\n        return -1;\n    }\n};\n```
['C++']