You have been freelancing for the military building their software. Suddenly you are woken up early to be informed that accidently Missiles have been launched all over the area by your neighbouring country and they have informed you the exact heights at which they are flying so that you can take them down.
You are now required to reprogram the missile system to take down these missiles. However you remember that due to budget cuts the current missile system is designed such that the next missile can be fired at a height greater than the previous one only and not below it.
For e.g if missiles are flying at heights 1,6,2,3 and you counter the first missile at height 1 followed by the next missile at height 6, then you cannot fire missiles lower than height 6 and thus missiles 2 and 3 go uncountered.
Your task is to program a software which takes the altitutes and calculates the maximum number of missiles that can be countered for a given number of missiles flying at various heights in order of their strike time. You also need to provide the missile numbers that are to be countered in their serial order.
The input begins with an integer number of test cases followed by an empty line after which each new line is an integer representing the altitude of the missile. At the end of each case their should be a blank line.
The output for each test case comprises of an integer N in the first line which is the number of missiles that can be countered. This is followed by N number of lines each specifying the altitude at which the missile was shot down in sequence.
Input: 1 1 6 2 3 5 Output: 4 1 2 3 5
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, JAR, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, CLOJ, FS|
Fetching successful submissions