>>110382354
>it sounds like you compute both answers then return the max
yeah, you are right. I forgot to say that. Since I don't know which case is the right one, I compute them both and choose the max of them.
>is there a way to know which one to use without computing both?
well, I computed both because each case is O(1). As for the actual formula, if K is part of the answer, then this holds, assuming S=C+M+Y:
(S/2) * (S/2) * K >= (S/3) * (S/3) * (S/3)
(S^2 * K) / 4 >= (S^3) / 27
K >= (4*S^3)/(27 * S^2)
K >= (4*S)/27
For this example: >>110382194
K=2, S=10
2 >= 4*10/27
2 >= 1.481...
since that is true, then taking K is the correct answer. This would imply that if K=1 or K=0, then the answer is not to take K. So, if we changed K to be 1 instead of 2:
C=3
M=4
Y=3
K=1
so, if we take K, then the answer is: 5*5*1=25
if we don't take K, then the answer is: 3*4*3=36.
So, the answer is not to take K (formula is correct).
For this example: >>110381309
K=0, S=15
0 >= 4*15/27
0 >= 2.222...
since that is not true, then taking K is not the correct answer. Although, this would imply that K has to be at least 3. So, for this one, if K=3 instead of K=0:
C=11
M=2
Y=2
K=3
so, if we take K, then the answer is: 8*7*3=168
if we don't take K, then the answer is: 5*5*5=125
So, the answer is to take K (formula is correct)
If K=2 instead of K=3, then:
if we take K, then the answer is: 8*7*2 = 112.
If we don't take K, then the answer is: 5*5*5=125.
So, the answer is not to take K (formula is also correct)
I am not sure if the formula is truly correct because S isn't always divisible by 2 or 3 and since there can't be decimals in any answer, then there might be some slight variations. For instance, if S=15, then 15/2*15/2 = 7.5*7.5 = 56.25, but we can't have decimals, so the true value would be 7*8 = 56. No idea if that extra 0.25 (in this case) that the formula doesn't take care of will make it fail.