Longest Increasing Subsequence Problem

hi all!The problem is An interesting subsequence(May challenge). My solution is giving runtime error on submitting but when i tested on codeforces(custom test),ideone and on my pc, it give correct answer for all of these!! why this is so??? help please…my code is here.

//