question :
Given n cities and m roads b/w them. Each road is represented as [L,R,X] L is the starting city, R — the ending city, and X the cost.
Also for all roads L<R . If there is a road from city L to R with cost X then one can travel b/w any two cities that lie b/w L and R with cost X.
Find the minimum cost to travel from 1 to N.
T<=10
N,M <= 1e5
L,R<=N
X<=1e6
My approach : sorting and priority queue , but it gave WA
sample:
2
4 1
1 3 10
4 3
1 4 10
1 2 5
2 4 3
op:
-1
8