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 DCE05 Problem - CodeChef in python is CodeChef: Practical coding for everyone and in c is CodeChef: Practical coding for everyone. 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