#K76487. Merge Sorted Cat IDs

    ID: 34653 Type: Default 1000ms 256MiB

Merge Sorted Cat IDs

Merge Sorted Cat IDs

You are given two sorted arrays of cat ID numbers. The first array has \(N\) elements and the second array has \(M\) elements. Your task is to merge these two arrays into one sorted array in non-decreasing order.

Input Format:

  • The first line contains two integers \(N\) and \(M\), representing the number of elements in the first and second array respectively.
  • The second line contains \(N\) space-separated integers (if \(N > 0\)).
  • The third line contains \(M\) space-separated integers (if \(M > 0\)).

Output Format:

  • Print the merged sorted array. The numbers should be separated by a single space.

For example, if the input is:

5 3
1 3 5 7 9
2 4 6

Then the output should be:

1 2 3 4 5 6 7 9

inputFormat

The input consists of three lines. The first line contains two integers \(N\) and \(M\) separated by a space. The second line contains \(N\) sorted integers. The third line contains \(M\) sorted integers. If \(N\) or \(M\) is zero, the corresponding line will be empty.

outputFormat

Output a single line containing the merged sorted list of cat IDs. Each number must be separated by a single space.

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