#C12843. Merge Sorted Arrays

    ID: 42315 Type: Default 1000ms 256MiB

Merge Sorted Arrays

Merge Sorted Arrays

You are given two sorted arrays in non-decreasing order. Your task is to merge these two arrays into a single sorted array in non-decreasing order.

The merging process should resemble the merge step in the Merge Sort algorithm. Consider that either of the arrays might be empty, and there can be duplicate elements.

Input is provided via standard input (stdin) and the result must be printed to standard output (stdout).

Example: For input arrays [1, 3, 5] and [2, 4, 6] the output should be [1, 2, 3, 4, 5, 6].

inputFormat

The input consists of four lines:

  1. An integer n1 denoting the number of elements in the first array.
  2. n1 space-separated integers representing the first sorted array.
  3. An integer n2 denoting the number of elements in the second array.
  4. n2 space-separated integers representing the second sorted array.

Note that if an array is empty, its corresponding line of elements may be omitted or be an empty line.

outputFormat

Output the merged sorted array as a single line of space-separated integers. If the merged array is empty, output an empty line.

## sample
3
1 3 5
3
2 4 6
1 2 3 4 5 6