Help in CHEFUNI

Can someone please provide me TC where my


[1] is giving WA.

I used the following approach:

If we want to go from (p, q, r) to (p+2, q+2, r+2), we have 7 different options:


cost[1] = 6 * A;
cost[2] = 3 * B;
cost[3] = 2 * C;
cost[4] = 2 * (A + B);
cost[5] = A + B + C;
cost[6] = 3 * A + C;
cost[7] = 4 * A + B;



I then removed (min(p, q, r)/2) + (min(p, q, r)/2) from p,q & r. Now, I'm left with either 1 or 0 at any 1 position, i.e. p, q or r.

Suppose we have p = 1 or 0, then I removed (min(q, r)-1) times q and r with min(B, 2 * A).

Now we are left with (Assuming r was min of q and r)


p = 1 or 0
q = (>=1)
r = 1



Now, to remove (1, 2, 1) we can brute force and then remove all the q > 2 and for (0, 2, 1) same approach.

I don't know if my logic is correct or not, but I made many Test Cases which passed this logic. Any kind of help would be appreciated. Thank you.


  [1]: https://www.codechef.com/viewsolution/16482287

Try test case

1

2 2 3 1000 2 3

Correct answer is 7

1 Like

Can anyone please tell the approach on how to solve it ??? I have no idea :frowning:

@vatsalsura
could you expalin why did you perform the following steps

then removed (min(p, q, r)/2) + (min(p, q, r)/2) from p,q & r. Now, I’m left with either 1 or 0 at any 1 position, i.e. p, q or r.

Suppose we have p = 1 or 0, then I removed (min(q, r)-1) times q and r with min(B, 2 * A).

Thank you. Didn’t think of this while solving it.

I am thinking to write an editorial on it if i get time. Stay tuned :slight_smile:

1 Like

This is perhaps the case that held my solution for nearly 5 days.

Yeah, I guess solving this would probably get an AC on my solution too.

Thanks a lot for the help :slight_smile:

Yeah…

I already know You are writing an editorial on CHEFUNI @soham1234:smiley:

https://discuss.codechef.com/questions/119435/chefuni-unofficial-editorial

here you go guys… any doubts put in the comment section there

1 Like

Thanks a lot

First of all, I am not entirely sure about the correctness of my solution but I will try and clear your doubts.

Suppose we have to go to (4, 5, 6) then we have min = 4(even). Now we divide min by 2, so min = min / 2 = 2. So we remove (min + min) from (p, q ,r) so now we are at (4, 4, 4). Hence (0, 1, 2) more to go. Now if our min was odd, for e.g. (3, 6, 7), min = 3. Dividing it by 2 will give min = 1. So, removing (1+1) this time from p, q & r. I am doing this to avoid odd even condition check for min. I am going from (p, q, r) to (p+2, q+2, r+2) so I am adding it twice.

I hope this helps.