Easiest Solution using Dijkstra !!!✌✌
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
```java []
class Edge{
    int node;
    int weight;

    public Edge(int n, int w){
        this.node = n;
        this.weight = w;
    }
}

class Tuple implements Comparable<Tuple>{
    int node;
    int cost;
    int time;

    public Tuple(int n, int c, int t){
        this.node = n;
        this.cost = c;
        this.time = t;
    }

    @Override
    public int compareTo(Tuple t2){
        return this.cost - t2.cost;
    }
}


class Solution {
    public int minCost(int maxTime, int[][] edges, int[] p) {
        int V = p.length;

        List<Edge>[] graph = new ArrayList[V];
        for(int i = 0; i < V; i++){
            graph[i] = new ArrayList<>();
        } 

        // adjList
        for(int[] edge : edges){
            int u = edge[0], v = edge[1], w = edge[2];
            graph[u].add(new Edge(v, w));
            graph[v].add(new Edge(u, w));
        } 

        // dijkstra
        int[] minTime = new int[V];
        Arrays.fill(minTime, Integer.MAX_VALUE);

        PriorityQueue<Tuple> pq = new PriorityQueue<>();
        minTime[0] = 0;
        pq.add(new Tuple(0, p[0], 0));

        while(!pq.isEmpty()){
            Tuple t = pq.remove();  // node, cost, time

            if(t.time > maxTime)    continue;

            if(t.node == V-1)   return t.cost;

            for(Edge nb : graph[t.node]){
                int time = t.time + nb.weight;

                if(time < minTime[nb.node]){
                    minTime[nb.node] = time;
                    pq.add(new Tuple(nb.node, t.cost + p[nb.node], time));
                }
            }
        }

        return -1;
    }
}
```
['Java']