750. Chocolate Promotion
Martin's friend owns a bakery that offers N different varieties of chocolates. However, there is a special promotion where if Martin buys one chocolate, he can get up to K additional chocolates for free, each of a different variety. The goal is to determine the minimum amount of money Martin needs to spend in order to buy all the different varieties of chocolates, taking advantage of this offer.
The input consists of T test cases. Each test case begins with a line containing two integers, N and K, representing the number of chocolate varieties and the maximum number of free chocolates Martin can get, respectively. The next line contains N integers, representing the prices of each chocolate variety.
For each test case, output a single integer on a new line, representing the minimum amount of money required to buy all the chocolate varieties.
1 4 2 3 2 1 4
1 <= T <= 50 1 <= N <= 1000 0 <= K <= N-1 1 <= Ai <= 100