Bye bye maximum edge - MarisaOJ: Marisa Online Judge

Bye bye maximum edge

Time limit: 1000 ms
Memory limit: 256 MB
Given an undirected, weighted graph of n vertices and m edges. If your path from u to v consists of k edges weigh w1,w2,...,wk, then the final weight of the path is calculated as follow: w1+w2+...+wk−max(w1,w2,...,wk) Find the weight of the shortest path from 1 to n. ### Input - The first line contains 2 integers n,m. - The next m lines, each line contains 3 integers u,v,w, there is an edge of weight w connecting u,v. ### Output - Print the weight of the shortest path from 1 to n, or print -1 if no path exists. ### Constraints - 1≤n,m≤2×105. - 1≤u,v≤n. - 1≤w≤109. ### Example Input: 33121232133 Output: 0