NZEC error while using python 3.6

I get a NZEC error when I run my code online. I am using python 3.6. However when I submit the code it gets accepted usually. In this problem I get NZEC even after submitting. Any solutions? I am new so I am sorry if my question is dumb.
https://www.codechef.com/problems/PIPSQUIK - Here is the problem
My code -

t_case = int(input())

for l1 in range(t_case):
num_bars,ed_height,duck,jump,l_force = map(int, input().split())
count = 0
for l2 in range(num_bars):
bar_type, bar_height = map(int, input().split())
if bar_type == 1:
if ed_height - duck <= bar_height:
count += 1
else:
l_force -= 1
if l_force == 0:
break
else:
count += 1
if bar_type == 2:
if jump >= bar_height:
count += 1
else:
l_force -= 1
if l_force == 0:
break
else:
count += 1
print(count)

Using break statements in lines 13 and 22 may be the reason. When you break out of your for loop, you are neglecting the rest of the (t, X) input left out from the N lines of input. Try using the continue statement instead:
if ( l_force < 0 ):
continue
or if you use the break statement, then add another loop to just take the rest of the input given.

In case of getting NZEC every time you RUN code on IDE, refer to this post: Python, Error while taking input

The best solution to this problem is, instead of trying to run, just submit the solution and it will get approved. I was facing the same issue, instead of running I just submit the solution and it got approved.

2 Likes