Logo
(追記) (追記ここまで)

12830번 - Newspapers 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 1024 MB300383414.050%

문제

In the beautiful Polish city called Mirkow, there are n intersections which are connected by n − 1 bidirectional streets. It is possible to travel between every pair of intersections using these streets.

Mirek works in Mirkow as a paper boy and he delivers newspapers to the villagers. For every street it is known how many people live there (it is also the number of newspapers he should deliver on that street). Each day he chooses two intersections and visits every house on the shortest path between them. Mirek’s daily salary is proportional to the average number of newspapers delivered on a single road (the number of delivered newspapers divided by the number of traversed roads).

At first, Mirek tried to be smart by delivering newspapers only on the road with the highest number of habitants, but the boss found out what his strategy was and tried to stop it, because too many people were not getting their newspapers. The boss gave Mirek an additional constraint: he had to choose a route containing not less than k roads.

Help Mirek and find the optimal path for him.

Given the description of Mirkow, find a path containing k streets or more with the highest number of delivered newspapers per road.

입력

On the first line of input there are two integers n and k (1 ≤ n ≤ 50 000, 1 ≤ k ≤ n−1) – the number of intersections in Mirkow and the minimal length of Mirek’s path. On the next n − 1 lines there are descriptions of streets. Each description consists of three integers a, b and c (1 ≤ a < b ≤ n, 0 ≤ c ≤ 106) – they mean that there is a street connecting intersections a and b and on this road there live c people.

You can assume that there exists a path of length k.

출력

Output one number – the average number of delivered newspapers on a single road in the optimal route. The output will be considered correct if the difference between it and the correct answer is less than 10−6.

제한

예제 입력 1

5 2
1 2 4
2 3 1
3 4 3
3 5 3

예제 출력 1

3.00000000

힌트

출처

Camp > Visegrad Programming Contests Preparation Camp > VPCPC 2014 62번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /