Alice is throwing a birthday party for her son. She initially has n bowls of chocolates (c1,
Question:
Alice is throwing a birthday party for her son. She initially has n bowls of chocolates (c1, c2, c3... cn) are the number of chocolates in each bowl) and she needs to distribute them among the children (one bowl each child), But k children arrive at the party (k>=n). Now she needs to prepare k bowls of chocolates. For that, she needs to transfer chocolates from the already filled bowls to the empty ones. Also, the calorie intake of a child by eating a bowl of chocolate is m² (where m is the number of chocolates in that bowl). She needs to divide the chocolates into k bowls such that the calorie intake per child can be minimized. Input Format The first line contains an integer t, denoting the number of test cases. The next line contains two integer n and k (1<=n<=k=104): the initial number of bowls and the number of children arrived. The next line contains n integer c1, c2, c3... cn (1<=ci<=105): chocolates in each bowl It is guaranteed that the sum of all ci is at least k. Output Format: Output one integer: the minimum sum of calorie inta of the children.
Sample Testcase #0
Testcase
Input
1
3 6
3 2 1
Testcase Output
6
Introduction to Probability and Statistics
ISBN: 978-1133103752
14th edition
Authors: William Mendenhall, Robert Beaver, Barbara Beaver