Problem A
Longest Increasing Subsequence
We say that an integer sequence is increasing if
the numbers in the sequence increase (rather than decrease or
stay the same). For example, the following is an increasing
sequence of length
A subsequence of a sequence uses some of the same
members, in the same order, but may leave some out. For
example, if we have the following (non-increasing) sequence of
length
then
Write a program that, given a sequence of integers, finds a subsequence that is increasing and is as long as possible.
Input
The input consists of between
Output
For each test case, output a line containing the length of a
longest increasing subsequence, followed by a line containing
the indices of the elements in one such sequence (the first
element has index
Sample Input 1 | Sample Output 1 |
---|---|
10 1 2 3 4 5 6 7 8 9 10 10 1 1 1 1 1 1 1 1 1 1 10 5 19 5 81 50 28 29 1 83 23 |
10 0 1 2 3 4 5 6 7 8 9 1 7 5 0 1 5 6 8 |