#Lutece0556. Building Roads
Building Roads
Migrated from Lutece 556 Building Roads
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 the war between Country and Country , all the roads in Country have been destroyed. Qiqi, the king of Country wants to build some roads to connect all cities (it means that starting from every city, we can go to any other cities through roads Qiqi built) as soon as possible.
Every road takes one day to build and every day Qiqi can build only one road. Building the road between city and city costs units money, where and are the population of city and city . What is the maximum and minimum cost if Qiqi wants to connect all cities in the shortest time?
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 is an integer () in a single line, representing the number of cities in Country . The next line lists integers describing the population of each city.
All cities' population are between and (inclusive).
Output
For each test case, print Case #t:
first, in which is the number of the test case starting from . Then output the minimum and maximum cost.
Samples
1
3
1 2 3
Case #1: 2 3
Note
Huge input/output. Please use scanf/printf
for C/C++
.
For the first sample, we can build the roads between and , and to get the minimum cost of . And build the roads between and , and to get the maximum cost of .
Resources
10th UESTC Programming Contest Preliminary