PIPSQUIK (problem code)

I don’t know why my answer is not accepted , although all the test cases were passed.
Here is my solution link–

Problem Link–

@ujjwalgupta303 You are traversing the whole, whereas it is given in the question that you have to stop when l becomes 0.
Therefore, when l becomes 0, then you have to come out of the loop and stop incrementing the value of count as well.
Hope this helps.

I think the problem with code is that the use of if else is incorrect.
Let say Edward has got type two barrier but he is not able to pass and he has its force remaining so as per your code he will enter the second if statement and if he is no able to jump the there is no way to use his force because as per condition flow of control is on the if so else will not be executed.
This is my AC link CodeChef: Practical coding for everyone

you are using if and the if else which is wrong.You must use a proper set of if else statement like if > else if > else
and in else condition if l == 1 use must break the loop without incrementing the ans because you won’t be having enough power to move forward