#C13666. Median of Two Sorted Arrays

    ID: 43229 Type: Default 1000ms 256MiB

Median of Two Sorted Arrays

Median of Two Sorted Arrays

Given two sorted arrays of integers, your task is to find the median of the two arrays combined. The median is defined as follows:

\[ \text{median} = \begin{cases} a[\frac{n}{2}] & \text{if } n \text{ is odd} \\ \frac{a[\frac{n}{2}-1] + a[\frac{n}{2}]}{2} & \text{if } n \text{ is even} \end{cases} \]

If both arrays are empty, consider the median as 0.0.

inputFormat

The first line contains two integers \(m\) and \(n\), representing the sizes of the two arrays. The second line contains \(m\) integers (if \(m > 0\)), representing the first sorted array. The third line contains \(n\) integers (if \(n > 0\)), representing the second sorted array. For an empty array (i.e. when \(m = 0\) or \(n = 0\)), the corresponding line will be empty.

outputFormat

Output a single floating-point number which is the median of the combined sorted array. The result should be printed with one decimal place.

## sample
2 1
1 3
2
2.0