Problems
Increasing subsequence
Increasing subsequence
Given n (1 ≤ n ≤ 105
) integers x1
, x2
, ..., xn
(1 ≤ xi
≤ 60000). Delete from them the least amount of numbers so that the rest were in ascending order.
Input
First line contains the number n. In the second line the integers x1
, x2
, ..., xn
are given.
Output
Print in the first line the amount of not erased numbers, in the second print the list of unerased numbers in the original order. If several answers exist, print any.
Input example #1
6 2 5 3 4 6 1
Output example #1
4 2 3 4 6