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())