Equalize the three numbers

883 Views Asked by At

You have three numbers, $x, y, z$. You are allowed the following two operations on these numbers.

  • Choose any two numbers and increase them by $1$.
  • Else choose any number and increase them by $2$.

Find the minimum number of operations to make the three numbers equal.

Eg. $x = 2, y = 5, z = 4$. Minimum operations is $2$.

I cannot seem to come up with the solution. Please help.

1

There are 1 best solutions below

2
On BEST ANSWER

Let $x+y+z=s$
where $x>y\ge z$ or $x\ge y>z$
Now the ultimate sum should be either $3x$ or $3(x+1)$ as all the numbers will be equal and the sum will have the same parity as the initial(it increase by 2)
Now since highest value i.e $x=5$
So $3x=15$ and $3(x+1)=18$
Parity of $x+y+z=11 $ is odd as $15$. So $15$ will be the ultimate sum.
Now, $15-11=4$ which is increase in $s$.
At each step it increases by $2$ so minimum steps=${4\over 2} =2$

PS: Variables are different than the ones in the question.