Олимпиадный тренинг

Задача 27052. Increasing subsequence


Задача

Темы:
Given N integers X1, X2, ..., XN. It is required to cross out the minimum number of numbers from them so that the remaining ones go in ascending order.
 
Input
The first line contains the number N. The next line contains N numbers separated by a space. 1 <= N <= 10,000, 1 <= Xi <= 60,000.
 
Output
The first line displays the number of non-crossed out numbers, the second - the non-crossed out numbers themselves, separated by a space, in the original order. If there are several options, output any one.

Enter Output
5
1 3 5 2 4
3
1 3 5