C++: Dijkstra MOdification
priority_queue alias heap will take care of minCost like we usaully do in Dijkstra.\nkey point is time. \npush a node again to heap if u can reach it in less ti
priority_queue alias heap will take care of minCost like we usaully do in Dijkstra.\nkey point is time. \n**push a node again to heap if u can reach it in less time than before**\n\n\n\n```\nclass Solution {\npublic:\n    struct myComp {\n      bool operator()(vector<int>& a,vector<int> &b){\n          return a[1] > b[1];\n      }\n    };\n    int minCost(int maxTime, vector<vector<int>>& edges, vector<int>& p) {\n        \n     priority_queue<vector<int>,vector<vector<int>>,myComp> pq;\n     pq.push({0,p[0],0});\n     int n = p.size();\n        \n     vector<vector<pair<int,int>>> graph(n);\n     for(auto it : edges){\n         graph[it[0]].push_back({it[1],it[2]});\n         graph[it[1]].push_back({it[0],it[2]});\n     }\n     vector<int> visited(n,0);\n     \n     while(!pq.empty()){\n         vector<int> curr = pq.top();\n         pq.pop();\n         if(curr[2] > maxTime){\n             continue;\n         }\n         if(curr[0] == n-1){\n             return curr[1];\n         }\n        \n         for(auto it : graph[curr[0]]){\n             if(visited[it.first] && visited[it.first] <= it.second+curr[2]){\n                 continue;\n             }\n             visited[it.first] = it.second+curr[2];\n             if(it.second+curr[2] <= maxTime){\n                 pq.push({it.first,curr[1]+p[it.first],curr[2]+it.second});\n             }\n         }\n         \n     }\n      \n        return  -1;\n        \n        \n    }\n};\n```
['C', 'Heap (Priority Queue)']