getting tle even after using efficient algorithm.

Can anyone explain why am i getting tle in the below-mentioned problem?
I am using nlogn version of LIS for the problem.

link to my solution: dN56xe - Online C++0x Compiler & Debugging Tool - Ideone.com
link to the problem: SPOJ.com - Problem BRDGHRD

Thanks in advance.