Johnny and the Beanstalk problem

First, of all description of this question is too bad. But, i managed to solve it.

But, i have a doubt in this problem when the previous count or sum is less than the current input of the user then i break the loop and print No as a answer. But, what about the rest of the input how they can be handled. They can become the input for the next test case.

I solve it both ways by breaking the loop immediately, and by reading the whole input stream. Both, works fine on online judge.

You can check both the solutions here and here.

1st one is faster takes 0.20sec and 2nd one takes 0.36sec

@sobhagya Both links are to the same solution…please correct it.

@argonaut link problem is fixed.

Hi, Just few minutes before I solved this problem (after reading this). I have the same question as you do. I surmised it is due to the unique arrangement of the test cases and we just just getting lucky. Of-course without break is the correct way to solve this problem.

//