307891: CF1431C. Black Friday
Description
There is a local shop in your area getting prepared for the great holiday of Black Friday. There are $n$ items with prices $p_1, p_2, \dots, p_n$ on the display. They are ordered by price, so $p_1 \le p_2 \le \dots \le p_n$.
The shop has a prechosen discount value $k$. The Black Friday discount is applied in the following way: for a single purchase of $x$ items, you get the cheapest $\lfloor \frac x k \rfloor$ items of them for free ($\lfloor \frac x k \rfloor$ is $x$ divided by $k$ rounded down to the nearest integer). You can include each item in your purchase no more than once.
For example, if there are items with prices $[1, 1, 2, 2, 2, 3, 4, 5, 6]$ in the shop, and you buy items with prices $[1, 2, 2, 4, 5]$, and $k = 2$, then you get the cheapest $\lfloor \frac 5 2 \rfloor = 2$ for free. They are items with prices $1$ and $2$.
So you, being the naive customer, don't care about how much money you spend. However, you want the total price of the items you get for free to be as large as possible.
What is the maximum total price of the items you can get for free on a single purchase?
InputThe first line contains a single integer $t$ ($1 \le t \le 500$) — the number of testcases.
Then the description of $t$ testcases follows.
The first line of each testcase contains two integers $n$ and $k$ ($1 \le n \le 200$; $1 \le k \le n$) — the number of items in the shop and the discount value, respectively.
The second line of each testcase contains $n$ integers $p_1, p_2, \dots, p_n$ ($1 \le p_i \le 10^6$) — the prices of the items on the display of the shop. The items are ordered by their price, so $p_1 \le p_2 \le \dots \le p_n$.
OutputPrint a single integer for each testcase: the maximum total price of the items you can get for free on a single purchase.
ExampleInput5 5 2 1 3 4 6 7 6 3 1 2 3 4 5 6 6 3 3 3 4 4 5 5 1 1 7 4 4 1 3 3 7Output
7 4 6 7 1