This solution is for problem code: PIPSQUIK in the beginner section of practice and learn.
I wrote a code which I considered was the most efficient and kept getting NZEC errors, while another code which ran through more iterations than mine got the right answer. Am i missing something in python?
My code:
for _ in range(int(input())):
n,h,y1,y2,l=map(int,input().split())
for z in range(n):
a,b=map(int,input().split())
if a==1:
if(h-y1>b):
l-=1
else:
if(y2<b):
l-=1
if(l<1):
print(z)
break
else:
print(n)
Code that got passed:
cook your dish here
for _ in range(int(input())):
n, h, y1, y2, l = map(int, input().split())
ans = 0
for _ in range(n):
t, x = map(int, input().split())
if t == 1:
if h-y1 > x: l -= 1
else:
if y2 < x: l -= 1
if l > 0:
ans += 1
print(ans)
Even though my code runs for lesser iterations, i got an NZEC error. It is also to be noticed that when the person whose code got passed, usage of the break statement is causing an NZEC error and not using it leads to a right answer. SHould i learn something before continuing.
Friends, i have got the reason for the nzec error.
The reason is that the ide is not able to read our input.
The main cause of this error is that we forget to give our input in custom input section and without giving input we run our code and that is why we get error.
So to get rid of nzec error, what we should do is to copy the input from the question and paste it in the custom input section and then run the code.
this will surely help.
even after doing this you get nzec error then surely there is error in your code and try your code in some other ide to identify the error.