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

32428번 - Steppe on It 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 1024 MB20121066.667%

문제

The gas pedal on the floor. Squealing tires. Wailing sirens. Emergency vehicles do whatever is necessary to reach their target locations as quickly as possible. Time is critical because lives often depend on it.

Providing emergency services is always challenging, especially for sparsely populated areas such as the Kazakh Steppe. The cost of building infrastructure is high compared to the number of people served. It is therefore important to minimize both the number of roads and the number of vehicles. On the other hand, it is also vital to minimize the response time of emergency services.

This problem considers a road network that already minimizes the number of roads, which means that any two villages are connected by exactly one path. Thanks to a government grant, the Kazakh Steppe Fire Department recently acquired some shiny new fire engines. The department wants to establish fire stations in some of the villages and allocate the fire engines to them in a way that optimizes the guaranteed response time.

Your task is to find an optimal placement of fire engines that minimizes the time needed for any village to be reached by a fire engine. You can neglect the time needed to assemble the fire crew and start the engine as well as the time to travel across any villages. The response time is determined solely by traveling along the roads.

입력

The first line contains two integers: the number of villages $n$ (1ドル ≤ n ≤ 100,円 000$) and the number of fire engines $f$ (1ドル ≤ f ≤ n$).

This is followed by $n-1$ lines numbered from 2ドル$ to $n$. Line number $i$ contains two integers $v_i$ (1ドル ≤ v_i < i$) and $t_i$ (1ドル ≤ t_i ≤ 10,円 000$) meaning that there is a two-way road between villages $i$ and $v_i$ that can be traveled in time $t_i$.

출력

Output the minimum response time that can be guaranteed by placing fire engines into $f$ villages.

제한

예제 입력 1

6 2
1 8
2 7
2 7
3 6
3 5

예제 출력 1

8

예제 입력 2

3 3
1 1000
2 1000

예제 출력 2

0

힌트

출처

ICPC > World Finals > ICPC World Finals 2024 I번

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

출처

대학교 대회

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

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