GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Tuesday 10 May 2022

Equal Candies Codeforces Solution | Codeforces Problem Solution 2022

B. Equal Candies
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

There are n boxes with different quantities of candies in each of them. The i-th box has ai candies inside.

You also have n friends that you want to give the candies to, so you decided to give each friend a box of candies. But, you don't want any friends to get upset so you decided to eat some (possibly none) candies from each box so that all boxes have the same quantity of candies in them. Note that you may eat a different number of candies from different boxes and you cannot add candies to any of the boxes.

Solution Click Below:-  CLICK HERE

What's the minimum total number of candies you have to eat to satisfy the requirements?

Input

The first line contains an integer t (1t1000) — the number of test cases.

Most Similar Words Codeforces Solution

The first line of each test case contains an integer n (1n50) — the number of boxes you have.

The second line of each test case contains n integers a1,a2,,an (1ai107) — the quantity of candies in each box.

Output

For each test case, print a single integer denoting the minimum number of candies you have to eat to satisfy the requirements.


Join Now for Solution:- 

No comments:

Post a Comment