chopsticks prob: getting W.A.

Getting W.A. can anybody provide me the test case where my solution is giving W.A. Problem link: http://www.codechef.com/problems/TACHSTCK … and … solution link: http://www.codechef.com/viewsolution/4861828 thanks to all of you in advance…

A very small test case where your code fails is:

  • 5 2
  • 9
  • 8
  • 7
  • 6
  • 5
  • Correct answer for above test case is 2 but your program out putted answer is 3. I saw your approach, your logic is correct but there is a small bug in your program, i hope you can identify it with above test case.
  • if you cant comment below i will help you. happy coding :slight_smile:
1 Like

there was a small bug in program at line no 22 just replacing
for(i=n-1; i>=0; i–) with
for(i=n-1; i>0; i–)will solve the problem…