count the length of longest increasing subsequence in O(nlgn)