408405: GYM103114 I Iahaxiki's journey II - enjoying
Description
Fahaxiki got the opportunity to participate in live competitions through an online competition, and will go to the beautiful Wuhan University to participate in the game. Although they traveled at their own expense on the weekend, they didn't want to miss the opportunity of this trip, so they ask you to help them calculate some problems so that they can get a better travel experience.
In order to simplify the problem, we abstract the developed traffic in Wuhan into some weighted undirected edges, connecting the whole Wuhan into a tree. Find the length of the longest simple path containing k nodes in this tree. A simple path means that the vertices on the path do not overlap with each other.
InputThe first line contains two integers $$$n, k (1 \leq n, k \leq 10^5)$$$, and $$$k$$$ doesn't exceed diameter of the tree.
Then next $$$n - 1$$$ lines, each lines contains three integers $$$a, b, c(1 \leq a, b \leq n, 1 \leq c \leq 10^3)$$$, denote there is an edge between $$$a, b$$$ and length is $$$c$$$.
OutputOutput the length of the requested path
ExampleInput4 3 3 4 45 2 3 89 3 1 18Output
134