#P2176. Maximizing FJ's Morning Walk Increase
Maximizing FJ's Morning Walk Increase
Maximizing FJ's Morning Walk Increase
FJ starts his day by walking from his house in field to the barn in field . The farm consists of fields connected by 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 by one with length ). Note that after this change, FJ will recalculate his route and take the new shortest path from field to field .
Your task is to compute the maximum possible increase in the shortest path distance from field to field that the cow can force, by optimally choosing the road to double.
In mathematical terms, let be the original shortest distance from to , and let be the new shortest distance if the length of road is doubled. You need to output (\max_{e},(d_e-d)).
inputFormat
The first line contains two integers and , where represents the number of fields and represents the number of roads. Each of the following lines contains three integers , , and , indicating that there is a bidirectional road connecting field and field with length . 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 to field after doubling the length of one road.
sample
3 3
1 2 1
2 3 1
1 3 3
1
</p>