Back to the Problem
Patience sorting with bisect_right so equal elements extend the run.
Complexity: O(N log N)