아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Image Labeler

메모리 제한1024 MB

요약
정렬한 지역 인구를 M개 범주로 나누어 각 범주의 중앙값 합이 최대가 되도록 배정한다.
난이도

보통10점 중 5점

유형
정렬, 그리디, 수학
정답자
아직 제출이 없습니다

문제

Crowdsource is organizing a campaign for Image Labeler task with participants across N\mathbf{N} regions. The number of participants from each of these regions are represented by A_1,A_2,…,A_N\mathbf{A\_1}, \mathbf{A\_2}, \dots, \mathbf{A\_N}.

In the Image Labeler task, there are M\mathbf{M} 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 two "middle" numbers, therefore the median is defined as the arithmetic mean (average) of the two middle values.)

For example, imagine that we have N=3\mathbf{N}=3 regions with A_1=5\mathbf{A\_1}=5, A_2=8\mathbf{A\_2}=8, and A_3=9\mathbf{A\_3}=9 participants respectively and we want to assign them to M=2\mathbf{M}=2 categories. If we assign regions 22 and 33 to category 11 and region 11 to category 22, then the success metric would be median of A_2=8,A_3=9 +\\{A\_2=8, A\_3=9\\}\ + median of A_1=5=8+92+5=8.5+5=13.5\\{A\_1=5\\} = \frac{8 + 9}{2} + 5 = 8.5 + 5 = 13.5. We can also assign regions 11 and 22 to category 11 and region 33 to category 22. Then the success metric would be equal to the sum of the median of A_1=5,A_2=8\\{A\_1=5, A\_2=8\\} and the median of A_3=9\\{A\_3=9\\}, which is 5+82+9=6.5+9=15.5\frac{5+8}{2} + 9 = 6.5 + 9 = 15.5.

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.

입력

The first line of the input gives the number of test cases, T\mathbf{T}. T\mathbf{T} test cases follow.

The first line of each test case contains two integers N\mathbf{N} and M\mathbf{M}: the number of regions, and the number of categories respectively.

The next line contains N\mathbf{N} integers A_1,A_2,…,A_N\mathbf{A\_1}, \mathbf{A\_2}, \dots, \mathbf{A\_N}.

출력

For each test case, output one line containing Case #x: y, where xx is the test case number (starting from 1) and yy is the maximum possible value of the success metric.

yy will be considered correct if it is within an absolute or relative error of 10−610^{-6} of the correct answer. See the FAQ for an explanation of what that means, and what formats of real numbers we accept.

제한

  • 1≤T≤1001 \le \mathbf{T} \le 100.
  • 1≤N≤1041 \le \mathbf{N} \le 10^4.
  • 1≤M≤1041 \le \mathbf{M} \le 10^4.
  • 1≤M≤N1 \le \mathbf{M} \le \mathbf{N}.
  • 1≤A_i≤1051 \le \mathbf{A\_i} \le 10^5, for all ii.

예제2

  1. 예제 1

    입력
    1
    3 2
    11 24 10
    
    예상 출력
    Case #1: 34.5
    
  2. 예제 2

    입력
    1
    5 1
    6 2 5 1 9
    
    예상 출력
    Case #1: 5.0