#P2491. [SDOI2011] 消防
[SDOI2011] 消防
Description
There are cities in a country. Any two of these cities are connected and have a unique path between them. Each road connecting two cities has length .
The people of this country have a passion for flames beyond the universe, so the most prosperous industry is firefighting. Since the government cannot tolerate the people's enthusiasm (massive firefighting budget expenditure) yet can do nothing about it (public support in presidential elections), they can only try every means to improve firefighting capacity.
Now the country's budget is sufficient to build a firefighting hub along a path (with both endpoints being cities) whose total length is no more than . To maximize the hub's utilization, it is required to minimize the maximum distance from all other cities to this path.
You are assigned to oversee this project, and of course you need to know where to place the hub.
Input Format
The input contains lines:
- Line : two positive integers and , separated by a space. Here is the number of cities, and is the upper bound on the path length. Nodes are numbered .
- From line to line : each line gives positive integers, representing the two endpoints and the length of one edge. For example,
2 4 7means the length of the edge connecting nodes and is .
Output Format
Output a single non-negative integer, which is the minimal possible value of the maximum distance from any city to the chosen path.
5 2
1 2 5
2 3 2
2 4 4
2 5 3
5
8 6
1 3 2
2 3 2
3 4 6
4 5 3
4 6 4
4 7 2
7 8 3
5
Hint
For of the testdata, .
For of the testdata, .
For of the testdata, , .
2024/1/28 added a set of hack testdata.
Translated by ChatGPT 5
京公网安备 11011102002149号