Merge two sorted arrays
Given two sorted arrays and of lengths n and m, you are asked to obtain a new array by combining those two that would be sorted as well.
Input
The first line of the input contains two integers n and m (1 ≤ n, m ≤ ).
The second line contains n space-separated sorted integers ( ≤ ≤ ).
The last line contains m space-separated sorted integers ( ≤ ≤ ).
Output
The program should print n+m space-separated integers in increasing order representing the combination of a and b.
Examples
Input | Output |
|---|---|
3 5 | -3 -2 -1 0 1 1 4 8 |
Constraints
Time limit: 5 seconds
Memory limit: 512 MB
Output limit: 25 MB