Longest increasing subsequence, dynamic programming