#P2176. Maximizing FJ's Morning Walk Increase

    ID: 15457 Type: Default 1000ms 256MiB

Maximizing FJ's Morning Walk Increase

Maximizing FJ's Morning Walk Increase

FJ starts his day by walking from his house in field 11 to the barn in field NN. The farm consists of NN fields connected by MM bidirectional roads, each with a positive length. There is a unique route order such that one can travel between any two fields. Every time FJ moves from one field to another, he always takes a route with the minimum total distance.

A mischievous cow decides to disrupt FJ's routine by choosing one road and doubling its length (i.e. replacing a road with length ww by one with length 2w2w). Note that after this change, FJ will recalculate his route and take the new shortest path from field 11 to field NN.

Your task is to compute the maximum possible increase in the shortest path distance from field 11 to field NN that the cow can force, by optimally choosing the road to double.

In mathematical terms, let dd be the original shortest distance from 11 to NN, and let ded_e be the new shortest distance if the length of road ee is doubled. You need to output (\max_{e},(d_e-d)).

inputFormat

The first line contains two integers NN and MM, where NN represents the number of fields and MM represents the number of roads. Each of the following MM lines contains three integers uu, vv, and ww, indicating that there is a bidirectional road connecting field uu and field vv with length ww. It is guaranteed that no two fields are connected by more than one road and the farm is connected.

outputFormat

Output a single integer: the maximum increase in the shortest path distance from field 11 to field NN after doubling the length of one road.

sample

3 3
1 2 1
2 3 1
1 3 3
1

</p>