The Quirky Professor
All submissions for this problem are available.
A mathematics professor uploads all necessary course material on his site. But he wanted his students to think and apply their minds. So he conceived an idea to get all of his students involved and share in his love for numbers. Every time they would access his site they would be given 10 sets of numbers from which they would have to find the longest increasing subsequences in each set. The answer for each would be the numbers appearing in the respective subsequence (if for one set there were more than one subsequence then the answer would be the union of all numbers appearing in the subsequences). Help the students solve the problems so that they can access the site.
Ten test cases (given one under another, you have to process all!). Each test case consists of two lines. In the first line there is a number n (1<=n<=100000). In the second line: an n-element permutation - n numbers separated by single spaces.
For every test case your program should write two lines. In the first line - the number of numbers appearing in your answer from the input permutation. In the second line the numbers separated by single spaces in increasing order.
Input: 5 2 1 4 5 3 (9 other test cases) Output: 4 1 2 4 5 (9 other test cases)
Note : This problem has been taken from previously solved questions.
|Time Limit:||1 - 3 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.5, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.