buy1 get1...please help..!!

why am i getting wrong answer for my code…while its giving me the desired output in my compiler
please check…here is my code…CodeChef: Practical coding for everyone

Becoz of this condition :

           if(y[j]%2==0)
            {
                y[j]=y[j]/2;
            }
            if(y[j]%2!=0)
            {
                y[j]=(y[j]/2)+1;
            }

suppose if y[j]=6 then it will come to 2nd if condition again. I hope you understant where it will go.
just a simple else there will get it AC. :slight_smile:

Link to AC : CodeChef: Practical coding for everyone

                if(y[j]%2==0)
                {
                    y[j]=y[j]/2;
                }
                else if(y[j]%2!=0)
                {
                    y[j]=(y[j]/2)+1;
                }
Happy coding :)
1 Like

thankss…