#BS0000425. Chọn pin cho xe điện (Charles in Charge)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Chọn pin cho xe điện (Charles in Charge)
Charles in Charge
Source: Kattis
Version: Phuoc Hung OJ Extended
Problem Statement
Charles commutes between his home in city and his workplace in city using highways. He wants an electric car. The available cars differ only in battery size; a larger battery costs more. He can recharge fully in any city but not between cities. Charging time is negligible.
There are cities numbered through and two-way highways. Highway joins cities , has length , and passes through no other city.
Let be the shortest total route length between home and work without battery restrictions. His wife Charlotte accepts a longer commute provided its length does not exceed , where is a given percentage.
A car with range after a full charge can traverse only highways of length at most . Find the minimum for which a route from city to city meets the total length limit. Since highways are bidirectional, the result also applies to the return journey.
Input
The first line contains integers : the number of cities, number of highways, and allowed percentage increase in route length.
Each of the next lines contains three integers , the endpoints and length of highway .
Output
Print a single integer: the minimum distance the car must be able to travel on one full charge.
Subtasks
- Subtask 1 (20 points): ; ; ; ; ; for every . Highways are bidirectional; a route from to exists.
- Subtask 2 (30 points): ; ; ; ; ; for every . Highways are bidirectional; a route from to exists.
- Subtask 3 (50 points): ; ; ; ; ; for every . Highways are bidirectional; a route from to exists.
Examples
Input 1
2 1 100
1 2 5
Output 1
5
Explanation 1
The only highway has length 5. A charge must cover the entire highway, so the required range is 5.
Input 2
9 8 15
1 9 16
1 4 4
4 5 4
5 6 4
6 8 4
4 7 5
7 8 5
8 9 4
Output 2
5
Explanation 2
The direct route is 16, giving a limit of . Route has length and maximum highway length 5. With range 4, the only simple route has length 20, exceeding the limit. Hence the answer is 5.

Input 3
9 8 30
1 9 16
1 4 4
4 5 4
5 6 4
6 8 4
4 7 5
7 8 5
8 9 4
Output 3
4
Explanation 3
The limit is now . Route uses five highways of length 4, for a total of 20. No highway is shorter than 4, so a smaller range cannot work.
Adapted from Charles in Charge, BAPC 2016 Jury, under CC BY-SA 4.0.