Why this is giving WA for LEBAMBOO

SIR, ACCORDING TO ME I HV INCLUDED ALL THE POSSIBLE CASES FOR LEBAMBOO… BUT STILL DON’T KNOW WHY IT IS GIVING LEBAMBOO…
QUESTION LINK – http://www.codechef.com/OCT13/problems/LEBAMBOO/
SOLUTION LINK — http://ideone.com/D2vvp2

Hey, use this little script to generate a test case file(input.txt) with random test cases.

Feed this test case file to your program(Linux command: cat input.txt|./a.out > output).

Feed the same file to one of the accepted solutions(Linux command: cat input.txt|./b.out > output_correct).

Then compare the two files(Linux command: vimdiff output output_correct)

See which case fails and then debug. :slight_smile:

2 Likes

@asvcracker007 Your code fails for this test case:
3

1 1 1

1 1 2

Answer should be -1 but your code returns 1.Here is ideone link. Handling such cases should get AC on your code.

Thnx @nitinj & @kcahdog

In ur solution after checking if ‘a’ is integer .U will have to check for every i whether (a-di+hi)/2 is integer or not.if for every i it gives integer then ans is ‘a’ otherwise -1…hi is initial height of plant i and di is final height of plant i…

(a-di+hi)/2 is the number of bottles used for plant i…