Logo
(追記) (追記ここまで)

26420번 - Image Labeler 서브태스크스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
서브태스크 참고 (추가 시간 없음) 1024 MB97623866.667%

문제

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

In the Image Labeler task, there are $\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 $\mathbf{N}=3$ regions with $\mathbf{A_1}=5,ドル $\mathbf{A_2}=8,ドル and $\mathbf{A_3}=9$ participants respectively and we want to assign them to $\mathbf{M}=2$ categories. If we assign regions 2ドル$ and 3ドル$ to category 1ドル$ and region 1ドル$ to category 2ドル,ドル then the success metric would be median of $\{A_2=8, A_3=9\}\ + $ median of $\{A_1=5\} = \frac{8 + 9}{2} + 5 = 8.5 + 5 = 13.5$. We can also assign regions 1ドル$ and 2ドル$ to category 1ドル$ and region 3ドル$ to category 2ドル$. Then the success metric would be equal to the sum of the median of $\{A_1=5, A_2=8\}$ and the median of $\{A_3=9\},ドル which is $\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, $\mathbf{T}$. $\mathbf{T}$ test cases follow.

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

The next line contains $\mathbf{N}$ integers $\mathbf{A_1}, \mathbf{A_2}, \dots, \mathbf{A_N}$.

출력

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

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

제한

  • 1ドル \le \mathbf{T} \le 100$.
  • 1ドル \le \mathbf{N} \le 10^4$.
  • 1ドル \le \mathbf{M} \le 10^4$.
  • 1ドル \le \mathbf{M} \le \mathbf{N}$.
  • 1ドル \le \mathbf{A_i} \le 10^5,ドル for all $i$.

Test Set 1 (4점)

시간 제한: 20 초

  • 0ドル \le \mathbf{N} - \mathbf{M} \le 1$.

Test Set 2 (6점)

시간 제한: 40 초

No additional constraints.

예제 입력 1

1
3 2
11 24 10

예제 출력 1

Case #1: 34.5

In this test, we can assign participants in regions to categories in 6ドル$ possible ways:

  • Assign $\{11, 24\}$ to category 1ドル$ and $\{10\}$ to category 2ドル,ドル in which case the success metric is $\frac{11 + 24}{2} + 10 = 17.5 + 10 = 27.5$.
  • Assign $\{24, 10\}$ to category 1ドル$ and $\{11\}$ to category 2ドル,ドル in which case the success metric is $\frac{24 + 10}{2} + 11 = 17 +たす 11 = 28$.
  • Assign $\{11, 10\}$ to category 1ドル$ and $\{24\}$ to category 2ドル,ドル in which case the success metric is $\frac{11 + 10}{2} + 24 = 10.5 + 24 = 34.5$.
  • 3ドル$ other ways, where assignments to category 1ドル$ and 2ドル$ are swapped, which does not alter the value of success metric.

So, the maximum possible value of the success metric is 34ドル.5$.

예제 입력 2

1
5 1
6 2 5 1 9

예제 출력 2

Case #1: 5.0

In this test, there is only one category, so participants in all regions will be assigned to it. The only possible value of the success metric is the median of $\{6, 2, 5, 1, 9\}$ which is 5ドル$.

힌트

출처

Contest > Google > Kick Start > Google Kick Start 2022 > Round D A번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /