#K95202. Merge and Remove Duplicates

    ID: 38811 Type: Default 1000ms 256MiB

Merge and Remove Duplicates

Merge and Remove Duplicates

This problem requires you to merge two sorted arrays and remove duplicates. You are given two sorted arrays. Your task is to output a single sorted array that contains every unique element from both arrays.

You can use the formula: $$ merged = sorted(\, set(arr1) \cup set(arr2) \,) $$ to generate the final answer.

inputFormat

The input is read from standard input (stdin) and consists of four lines:

  1. The first line contains an integer \( n \), representing the number of elements in the first array.
  2. The second line contains \( n \) space-separated integers in non-decreasing order.
  3. The third line contains an integer \( m \), representing the number of elements in the second array.
  4. The fourth line contains \( m \) space-separated integers in non-decreasing order.

outputFormat

Output to standard output (stdout) a single line containing the merged sorted list with unique elements, with numbers separated by a single space. If the resulting array is empty, output nothing.

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