시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
8 초 | 512 MB | 10 | 0 | 0 | 0.000% |
The judges of the South Pacific Programming Contest are planning their next secret karaoke meetup and are looking for a place to hold it. Last time, they asked Timothy to pick the location, but of course, he just picked somewhere really close to his house, and far from everyone else’s! This year, you would like to pick a meeting location that is fair.
All the judges live in the same city. The city consists of various locations in which the meeting could be held and roads that connect pairs of locations. The city is built such that for each pair of locations, there is exactly one path between them. Each road has a length and can be used to travel in either direction. You consider a meeting point fair if the distances from each of the judges’ houses are similar. For each location, its fairness score is the ratio A/B, where A is the minimum distance from the location to any judges’ house and B is the largest distance. What is the maximum fairness score for all vertices?
The first line contains two integers n (2 ≤ n ≤ 200 000), which is the number of locations in the city, and k (2 ≤ k ≤ n), which is the number of judges.
The next k lines describe the location of the judges’ houses. Each of these lines contains a single integer ℓ (1 ≤ ℓ ≤ n), which is the location of this judge’s house. No two judges live at the same location.
The next n − 1 lines describe the roads in the city. Each of these lines contains three integers u (1 ≤ u ≤ n), v (1 ≤ v ≤ n), and w (1 ≤ w ≤ 109), which denotes a road between locations u and v with a length of w.
Display the maximum fairness score as a reduced fraction.
3 2 2 3 1 2 1 1 3 1
1/1
2 2 1 2 1 2 10
0/1
5 3 5 2 4 3 1 1 1 4 1 1 2 1 3 5 1
1/2
10 4 1 5 8 9 3 4 5 3 2 20 4 9 5 2 8 6 6 2 3 5 7 7 10 2 4 4 1 17 7 2 5
5/16