 # Mistake in the PRPOTION code

I did the same thing as told in the editorial getting the maximum of the 3 numbers m times and then halving it . Even then i was getting WA . It would be great if someone points out what is wrong in the given code .

http://www.codechef.com/viewsolution/5082739

```
if(m>=30)
m=30;
```

This does not seem correct, may be try the limit 90 as explained in the editorial.

2 Likes

@goltu Dude the order of input is red green and blue. check your order of input ans also why are using the following statement:

if(m>30)
m=30;

remove this statement. Check this. It the AC version of your code.

1 Like

Why does he even do that? m>=30 then m=30? Just cant see how is this helpful in any possible way!

Based on the limit on the values in R, G, B, one can observe that using at most 90 operations, all values can be made zero. Hence, there is no point of applying more than 90 operations.

Like I said in the editorials that this optimization has little merit given that the maximum allowed value of m is 100. On the other hand, if m were allowed to be large (e.g., 109), this could have saved time.

2 Likes

I removed this condition even then it’s giving WA .

Meanwhile I used this condition earlier because the values in the arrays are less than 10^9. So if we divide them with 2 more than 30 times then denominator will be greater than 10^9 making them zero .

ThankYou so much . I don’t know how I missed out this minor detail .

@roman28 I used this condition earlier because the values in the arrays are less than 10^9. So if we divide them with 2 more than 30 times then denominator will be greater than 10^9 making them zero .