Same strategy working in C but not in python. What could be the reason?

Getting runtime(nzec) error for solution submitted in python whereas similar approach worked in C. Am I missing something that in python. The solution for http://www.codechef.com/problems/DCE05 in python is http://www.codechef.com/viewsolution/4087688 and in c is http://www.codechef.com/viewsolution/4087748. Can anyone point what is the wrong that Iam doing in python.

Instead of just :

a=input()

submit using:

a=int(raw_input().strip())

The reason may be that the author has left leading white spaces at the end of input,the strip() function just removes all the leading white spaces,there is no problem with these leading white spaces for ā€˜cā€™ because scanf() ignores them,where as for input() method in python,the input should be strictly integer.By the way I think your algorithm may not pass the Time limit? just think about it.I guess this may help you

1 Like
//