Python tle java ac!

I am getting a TLE in my python code whereas a code with the same complexity of O(n^2) in java, I am getting AC!!
My solution link for python is:http://www.codechef.com/viewsolution/3971729
My java solution link is:http://www.codechef.com/viewsolution/3970249

Check and let me know.

@complexgene

  1. first of all check others submission
  2. check whether anyone submit it in python during the contest
  3. Time limit for python is adjusted such that when same algo coded in python it passes test data.

btw there is also an O(nlogn ) approach to solve this problem and with that certainly you will not get this veridict so i think you should check this out i have provided an explanation of that at the end::


if you like this answer dont forget to cast votes::