#P1547. [USACO05MAR] Out of Hay S
[USACO05MAR] Out of Hay S
Description
Bessie plans to survey the hay situation of () farms, starting from farm . There are () bidirectional roads in total, and the total length of all roads does not exceed . There may be multiple roads between some pairs of farms, and all farms are connected.
Bessie wants to compute the length of the longest edge in a minimum spanning tree of this graph.
Input Format
The first line contains two integers .
Each of the next lines contains three space-separated integers , indicating there is a road between and with length .
Output Format
Output a single integer, the length of the longest edge in the minimum spanning tree.
3 3
1 2 23
2 3 1000
1 3 43
43
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号