#C8229. Median After Removals

    ID: 52188 Type: Default 1000ms 256MiB

Median After Removals

Median After Removals

You are given an array of n integers and a list of m integers to remove from the array. Remove each specified element once from the array. After removal, if the array becomes empty, output "Empty". Otherwise, sort the remaining elements and compute the median as follows:

  • If the number of remaining elements is odd, the median is the middle element.
  • If the number of remaining elements is even, the median is the average of the two middle elements, i.e. \(\frac{a_{\frac{n}{2}-1}+a_{\frac{n}{2}}}{2}\).

Note: The input is read from standard input (stdin) and the output must be written to standard output (stdout).

inputFormat

The input consists of four lines:

  1. An integer n, the number of elements in the array.
  2. n space-separated integers representing the array.
  3. An integer m, the number of elements to remove.
  4. If m > 0, then m space-separated integers representing the elements to remove. If m = 0, this line may be empty.

outputFormat

If the array is empty after removal, print Empty (without quotes). Otherwise, print the median. If the median is an integer, output it as an integer; if it is a fractional number, output it in decimal format.

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