PRPOTION explanation of test case

qstn:-CodeChef: Practical coding for everyone

please someone explain the last test case answer

that is

3 2 2 2

1 2 3

2 4

6 8

2 Likes
  • Red liquid portion = (1,2,3)
  • Green liquid portion = (2,4)
  • Blue liquid portion = (6,8) and only two minutes
  • for 1st minute select Blue liquid portion and reduce it to half
  • hence it becomes (r,g,b) = ((1,2,3),(2,4),(3,4))
  • now you can select green liquid portion or again blue liquid portion and reduce either of them by half
  • hence it becomes (r,g,b) = ((1,2,3),(1,2),(3,4)) if we consider Green portion
  • now 2 minutes completed so maximum of all portions is 4
  • so our final out put is 4
7 Likes

hey they changed the question but i have the solution for previous question
i will post after the contest

I implemented both solution - the one minimizing total amount and the one minimizing the max amount for one color and the latter got accepted, so the examples are correct, while description is not…


In a meantime my question on problem page was answered and problem statement fixed:

She would like to minimize the maximum amount of liquid among all of Red, Green and Blue colored potions. Formally Let v be the maximum value of amount of liquid in any potion. We want to minimize the value of v.

@varun1’s comment was misleading for problem setter probably:

varun1 @ 5 Oct 2014 07:41 AM:

“She would like to minimize the maximum amount of liquid among total of Red, total of Green and total of Blue.” Above statement would improve clarity

How can you halve the content of g in second step and not increase the r & b contents by 1?

@xiaoyu_02 I think you didnt read the question after they have updated the problem statement… Please read it once

hehe… same here bro, firtly i thought as usual ,only test cases has been updated , so i wasted 1 hour to implement a recursive solution for the original question… but thereafter while submitting i saw the whole problem statement is being updated…

@aniket20 Yes, I missed it! Thanks man! :slight_smile:

Aren’t we suppose to consider Blue potion only in the 2nd minute because it has a higher total sum?
2+4=6
3+4=7.
Because the question says, “She would like to minimize the maximum amount of liquid among TOTAL of Red, total of Green and total of Blue.”

1 Like

But now the question has changed…so now do we have to choose the color with greatest sum for each magic trick??