#P16881. [GKS 2022 #D] Image Labeler
[GKS 2022 #D] Image Labeler
Problem Description
Crowdsource is organizing a campaign for Image Labeler task with participants across regions. The number of participants from each of these regions are represented by .
In the Image Labeler task, there are categories. Crowdsource assigns participants to these categories in such a way that all participants from a region are assigned to the same category, and each category has at least one region assigned to it. The success metric of the campaign is measured by the sum of medians of the number of participants in each category. (Let us remind you here that the median of a list of integers is the "middle" number when those numbers are sorted from smallest to largest. When the number of integers in a list is even, we have "middle" numbers, therefore the median is defined as the arithmetic mean (average) of the middle values.)
For example, imagine that we have regions with , , and participants respectively and we want to assign them to categories. If we assign regions and to category and region to category , then the success metric would be $\operatorname{median}(\{A_2 = 8, A_3 = 9\}) + \operatorname{median}(\{A_1 = 5\}) = \frac{8+9}{2} + 5 = 8.5 + 5 = 13.5$. We can also assign regions and to category and region to category . Then the success metric would be equal to the sum of the median of and the median of , which is .
Your task is to find the maximum possible value of the success metric that can be obtained by assigning participants in regions to the categories.
Input Format
The first line of the input gives the number of test cases, . test cases follow.
The first line of each test case contains two integers and : the number of regions, and the number of categories respectively.
The next line contains integers .
Output Format
For each test case, output one line containing Case #: , where is the test case number starting from and is the maximum possible value of the success metric.
will be considered correct if it is within an absolute or relative error of of the correct answer.
1
3 2
11 24 10
Case #1: 34.5
1
5 1
6 2 5 1 9
Case #1: 5.0
Hint
In this test, we can assign participants in regions to categories in possible ways:
- Assign to category and to category , in which case the success metric is .
- Assign to category and to category , in which case the success metric is .
- Assign to category and to category , in which case the success metric is .
- other ways, where assignments to category and are swapped, which does not alter the value of success metric.
So, the maximum possible value of the success metric is .
Limits
.
.
.
.
, for all .
Test Set
.
Test Set
No additional constraints.