# Streamlining of the list of orderly masses in one

• Dano: list of the masses, each of which is streamlined (for certainty, whole numbers and increasing)

We need to make one of these clusters that will also be streamlined.

For example ((1.6) (2, 5, ,(3, 9, 12) / Main (1,2,3,4,5,6,8,9,12)

The basic condition is that the grading should be as fast as possible as possible (not yet limited), as the masses will be around 10 ^7-10 ^8, the number ~ 10 grand.

Lobby solution: to record everything in a series of volumes and to try to distort rapid or mergers (partial streamlining may yield merger gains)

But perhaps there's a quicker solution to the entry data (such as cuttings) that I'm asking you to help, because in this task, I'm worth any time gain.

• You need a merger.

Example algorithm in your case:

1. Start the current cell number in each of the masses
2. We'll pick a minimum from the current.
3. Cop it in the exit range and move the current element.
4. If all the masses are over, let's go. Otherwise, back to paragraph 2.

Example of algorithm:

1. `(*1, 4, 6), (*2, 5, 8), (*3, 9, 12)`the star is marked by current elements.
2. Selecting the minimum of the current one. Move: `(1, *4, 6), (*2, 5, 8), (*3, 9, 12) -> (1)`
3. Minimum = 2 moving: `(1, *4, 6), (2, *5, 8), (*3, 9, 12) -> (1, 2)`
4. Minimum = 3 moving: `(1, *4, 6), (2, *5, 8), (3, *9, 12) -> (1, 2, 3)`
5. Minimum = 4 moving: `(1, 4, *6), (2, *5, 8), (3, *9, 12) -> (1, 2, 3, 4)`
6. Minimum = 5, move: `(1, 4, *6), (2, 5, *8), (3, *9, 12) -> (1, 2, 3, 4, 5)`
7. Minimum = 6, move: `(1, 4, 6)*, (2, 5, *8), (3, *9, 12) -> (1, 2, 3, 4, 5, 6)`
8. Minimum = 8, move: `(1, 4, 6)*, (2, 5, 8)*, (3, *9, 12) -> (1, 2, 3, 4, 5, 6, 8)`
9. Minimum = 9, move: `(1, 4, 6)*, (2, 5, 8)*, (3, 9, *12) -> (1, 2, 3, 4, 5, 6, 8, 9)`
10. Minimum = 12, move: `(1, 4, 6)*, (2, 5, 8)*, (3, 9, 12)* -> (1, 2, 3, 4, 5, 6, 8, 9, 12)`
11. End.

2

2

2

2

2

2

2

2

2

2

2

2

2

2

2