Alternate Additions (ALTERADD)

In the solution of Alternate Addition ID: 80668633.

I am not understanding which test case is failing and why in my solution. I think my solution is perfect for each and every test case. Codechef has declared the solution is wrong solution.

Please respond on this

Do attach the necessary links of both, problem and solution, so that people can access it easily and help

1 Like

sorry for the late reply

Please find the link.

https://www.codechef.com/viewsolution/80668633

in your solution, where are you increasing value of B ?

You are adding +1 or +2 based on the parity of A.
The question asks you to add 1 if the operation number is odd…that is first time you will add 1, then second time you will add 2, then third time you will add 1, and so on…

Also your solution will result in TLE as A, B are of the order of 10^9.
You can do it in O(1)