#C6676. Minimum Candy Distribution Cost

    ID: 50462 Type: Default 1000ms 256MiB

Minimum Candy Distribution Cost

Minimum Candy Distribution Cost

You are given a number of test cases. In each test case, there are N children, each initially having a certain number of candies. Every child must have at least K candies. If a child has fewer than K candies, you must purchase the additional candies at a cost of C per candy.

The cost for a child with ai candies is computed as \(\max(0, K - a_i) \times C\). The total cost for a test case is the sum of the costs for all children.

Your task is to calculate and output the minimum total cost for each test case.

inputFormat

The first line of input contains an integer T, the number of test cases. For each test case, the input is structured as follows:

  • The first line contains three space-separated integers: N (the number of children), K (the minimum candies required for each child), and C (the cost per additional candy).
  • The second line contains N space-separated integers representing the number of candies each child initially has.

outputFormat

For each test case, output a single line containing the minimum cost required to ensure every child receives at least K candies.

## sample
1
3 5 2
2 3 6
10

</p>