#Lutece0571. Electric System Restore
Electric System Restore
Migrated from Lutece 571 Electric System Restore
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
After building and improving the traffic system of Country X, Qiqi wants to restore the electric system. Every City in Country X can be supplied by the base station or itself. The cost of transportation between base station and a city is the distance between them, i.e. if their coordinates are and , their distance equals to . Also, it costs to power itself for the city.
Due to some reasons, the number of cities powering themselves should be no more than . As the chief designer of Country X, it's your job to place the base station and assign the cities powering themselves to minimize the total cost. Note that you can place the base station at any integer point.
Input
There are multiple test cases. The first line of the input will be an integer () indicating the number of test cases.
For each test case there are two integers and (, , ) in a single line, representing the number of cities in Country X and Qiqi allows at most cities power itself. The next line lists integers, , describing the cost of power itself of each city. Then lines follow, each contains two integers and , indicating the coordinate of the city. for .
Output
For each test case, print Case #t:
first, in which is the number of the test case starting from . Then output the minimum costs.
Samples
1
4 1
2 2 2 2
1 1
1 2
2 1
2 3
Case #1: 4
Note
For the first sample, we should build the base station at and make the city power itself.
Resources
10th UESTC Programming Contest Final