# python runtime NZEC error

I looked at all previous post here in the forum, but I still can’t figure out why I’m getting this NZEC here.
I’m trying to solve SALARY, http://www.codechef.com/problems/SALARY
and here are my submissions http://www.codechef.com/status/SALARY,ishubhamch

http://www.codechef.com/viewsolution/2188157

``````#!usr/bin/env python
import sys
def check(n,wl):
i=0
valid=True
while i<n-1 and valid:
valid=(wl[i]==wl[i+1])
i+=1
return valid
def incr(n,wl,count):
mx=max(wl)
#print 'Inside incr: n= ',n,'mx= ',mx,'count= ',count
leftOne=False
for i in range(n):
if wl[i]==mx and leftOne==False:
leftOne=True
else:
wl[i]+=1
#print 'wl= ',wl
count+=1
if (check(n,wl)):
print count
return
else:
incr(n,wl,count)
return

def main(argv=None):
t=int(raw_input())
#print 't= ',t
while t>0:
t-=1
count=0
n=int(raw_input())
#print 'n= ',n
wStr=raw_input()
wl=wStr.split()
for i in range(n):
wl[i]=int(wl[i])
#print 'wl= ',wl
if check(n,wl):
print count
else:
incr(n,wl,count)
return 0

if __name__ == "__main__":
sys.exit(main())
``````
1 Like

did you read the editorial page for this problem ?

because the solution is much much simpler than what you implemented.

here is an example of my AC solution in Python.

good luck

1 Like

But still the question remains why a runtime error, it should be time limit exceeded (or wrong answer). Why is there a RUNTIME error?

2 Likes

Nice pythonic code!

Try it with main() instead of with sys.exit(main()). I never use sys.exit and rarely get NZEC.

//