I use the programming language; **Python**

The problem link; http://www.codechef.com/problems/D2/

I implemented a solution that can run in O(n^2*logk) where k is the length of the LIS, and n is the length of the sequence, however I get TLE. So I broke down my solution and submitted the algorithm for LIS which runs O(n*logk), yet I still get TLE.

Can anyone explain a faster method or is it because python is too slow?