#C12316. Merge and Sort Unique Integers

    ID: 41730 Type: Default 1000ms 256MiB

Merge and Sort Unique Integers

Merge and Sort Unique Integers

You are given two lists of integers. Your task is to merge the two lists, remove any duplicate values, and then output the resulting list in descending order.

The operation can be formally described by the formula:

\(result = \text{sorted}\Bigl(\{ x : x \in list1 \cup list2 \}\Bigr, \text{reverse order}\Bigr)\)

For example, if the two lists are [3, 1, 4] and [4, 5, 9], the unique merged list in descending order is [9, 5, 4, 3, 1].

inputFormat

The input is given via standard input (stdin) with the following format:

  1. The first line contains a single integer \(n\), representing the number of elements in the first list.
  2. The second line contains \(n\) space-separated integers, representing the first list.
  3. The third line contains a single integer \(m\), representing the number of elements in the second list.
  4. The fourth line contains \(m\) space-separated integers, representing the second list.

outputFormat

Output to standard output (stdout) a single line containing the integers of the merged and sorted list in descending order. The integers must be separated by a single space. If the resulting list is empty, output an empty line.

## sample
3
3 1 4
3
4 5 9
9 5 4 3 1