3 state Djikstra | C++ | 71%
\n//less cost are covered first hence only time contraint.\nclass Solution {\npublic:\n    int minCost(int maxTime, vector<vector<int>>& edges, vector<int>& pas
```\n//less cost are covered first hence only time contraint.\nclass Solution {\npublic:\n    int minCost(int maxTime, vector<vector<int>>& edges, vector<int>& passingFees) {\n        int n=passingFees.size();\n        vector<vector<pair<int,int>>> adj(n);\n        for(auto it: edges){\n            adj[it[0]].push_back({it[1],it[2]});\n            adj[it[1]].push_back({it[0],it[2]});\n        }\n        set<vector<int>> s;\n        vector<int> vis(n,1005);\n        s.insert({passingFees[0],0,0});\n        vis[0]=0;\n        while(!s.empty()){\n            vector<int> x=*s.begin();\n            s.erase(s.begin());\n            if(x[1]==n-1)\n                return x[0];\n            for(auto it: adj[x[1]]){\n                if(x[2]+it.second<vis[it.first] && x[2]+it.second<=maxTime){\n                    vis[it.first]=x[2]+it.second;\n                    s.insert({x[0]+passingFees[it.first],it.first,x[2]+it.second});\n                }\n            }\n        }\n        return -1;\n    }\n};\n```
['C']