### PROBLEM LINK:

**Author:** Naman Goyal

**Tester:** Aanya Jindal

**Editorialist:** Naman Goyal

### DIFFICULTY:

CAKEWALK

### PROBLEM:

The minimum number of transactions to be done to divide the money equally after 3 people paid (possibly) different amounts.

### QUICK EXPLANATION:

Number of transactions will be equal to 1 less than the number of people who haven’t paid the exact amount.

### EXPLANATION:

The problem statement makes it clear that there are three friends wants to divide the money equally among themselves.

Therefore, we need to find the average of the three numbers.

Since we have to make the least number of transactions.

It should be clear that the maximum number of transactions that can be made is 2 which will be the case when no one of them has paid the amount equal to the average amount.

Other two cases are 0 and 1.

0 when all three of them has paid the same amount

1 when one of them has paid the amount equal to the average amount

It is necessary to take into the account about the constraints that are in the range of long long for c++, java.

0<=a,b,c<=10^18

### AUTHOR’S AND TESTER’S SOLUTIONS:

Author’s solution can be found here.

Tester’s solution can be found here.