#K38862. Taco Bill Balancing
Taco Bill Balancing
Taco Bill Balancing
You are given a group of n friends who went out for tacos. They contributed varying amounts towards the bill, and your task is to determine how much each friend should pay or be reimbursed so that all friends pay an equal share.
Let \( T \) be the total amount contributed, and let \( n \) be the number of friends. The fair share for each friend is computed by:
[ \text{fair share} = \left\lfloor \frac{T}{n} \right\rfloor ]
The balance for each friend is then:
[ \text{balance}_i = \text{contribution}_i - \text{fair share} ]
A negative balance indicates the friend owes money, while a positive balance indicates the amount they should be reimbursed.
inputFormat
The input is read from standard input (stdin) and consists of two lines:
- The first line contains an integer n representing the number of friends.
- The second line contains n space-separated integers, where the i-th integer represents the amount contributed by the i-th friend.
outputFormat
Output a single line to standard output (stdout) containing n space-separated integers. Each integer represents the net balance of the corresponding friend. A negative number means the friend owes money, while a positive number means they should be reimbursed.
## sample3
100 200 300
-100 0 100
</p>