407168: GYM102697 139 Dynamic Sorting

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

139. Dynamic Sortingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output
This problem is worth 20 points.

Your computer outputs $$$n$$$ integers randomly. You think it might be a secret code, so you decide to make a list of the numbers, but maintain the list in sorted order as you add each number.

For example, if the computer output was $$$3$$$ $$$4$$$ $$$2$$$ $$$8$$$ $$$7$$$, you would first add $$$3$$$ to the list, making the list [3].

Then, you would add $$$4$$$ to the list, making the list [3, 4].

Then, you add $$$2$$$, putting it first in the list to maintain the list's sorted order. The list becomes [2, 3, 4]

The process proceeds until the list is [2, 3, 4, 7, 8] after the final step.

Input

The first line of input contains a positive integer $$$n$$$: the amount of numbers your computer has printed out.

The next $$$n$$$ lines contain $$$n$$$ integers: the numbers that your computer printed out.

Output

Output $$$n$$$ lines. On the $$$k$$$th line, output $$$k$$$ integers: the sorted list after adding the $$$k$$$th number from the computer's output to the list.

ExampleInput
5
3
4
2
8
7
Output
3
3 4
2 3 4
2 3 4 8
2 3 4 7 8

加入题单

算法标签: