#P11258. [GDKOI2023 普及组] 城市建设
[GDKOI2023 普及组] 城市建设
Problem Description
There are cities located at nodes . As the manager of the cities, Xiaoming wants to connect these cities with the minimum total cost. The cost of connecting cities mainly consists of the following two types.
Type 1: Build roads. Building a road between city and city costs .
Type 2: Set up management cities. For a city , you can upgrade it to a management city at a cost of .
Under the constraints that every road must be incident to at least one management city, and every non-management city can connect to only one edge, Xiaoming wants to know the minimum total cost to make all cities connected.
Input Format
The first line contains a positive integer , representing the number of cities.
The second line contains an integer , representing the cost to set up a management city.
Output Format
One line containing one integer, representing the minimum cost for Xiaoming to connect all cities.
6
3
12
1000
1000
32561
100000
10000
10099799
Hint
Sample Explanation
The minimum cost can be achieved by taking and as management cities, and connecting the five edges , , , , .
It can also be achieved by taking or as the management city and connecting all other nodes to it, which also gives the minimum cost.
Constraints
For of the testdata, .
For of the testdata, .
For another of the testdata, , .
For of the testdata, , .
Translated by ChatGPT 5