#t378. 最长上升序列(LIS)
最长上升序列(LIS)
Longest Increasing Subsequence
Background
Special for beginners, ^_^
Problem Description
Consider a sequence composed of distinct integers, denoted with (). If there exist indices such that , then this is called an increasing subsequence of length .
Given the original sequence, find its longest increasing subsequence.
For example, 13, 7, 9, 16, 38, 24, 37, 18, 44, 19, 21, 22, 63, 15.
In this example, 13, 16, 18, 19, 21, 22, 63 is an increasing subsequence of length 7, and at the same time 7, 9, 16, 18, 19, 21, 22, 63 is an increasing subsequence of length 8.
Input Format
One line containing several positive integers; the count is less than 100, and each value is less than 50000.
Output Format
Output two lines.
The first line outputs an integer .
The second line outputs integers, the longest increasing subsequence.
Sample Input 1
300 250 275 252 200 138 245
Sample Output 1
2
250 275
Constraints
1s, 1024KiB for each test case.