WA in finding Longest Increasing subsequence in nlogn time complexity

I am practising a problem in hackerearth called Inversion Graphs.

I have solved using Longest Increasing subsequence in O(nlogn) algorithm.
My solution has passed all the test cases except the one test case #7.

Surprisingly, my solution is similar to the editorial one.

Link to the code : https://ide.geeksforgeeks.org/gVj0qM3v7s

If the above link does not work, try this : https://pastebin.com/9SjFnkaD

Thank you in advance :slight_smile:

Go through this

I have implemented the same thing right? Any wrong in my code?