#K63747. Find the M-th Smallest Element in Merged Sorted Arrays
Find the M-th Smallest Element in Merged Sorted Arrays
Find the M-th Smallest Element in Merged Sorted Arrays
You are given two sorted arrays and a number M. Your task is to find the M-th smallest element in the union of these arrays. The arrays are provided in each test case along with their sizes.
For each test case, you will be given three integers: N (the length of the first array), K (the length of the second array), and M. Following these, two lines contain the sorted integers of the first and second arrays respectively.
Note: The M-th smallest element is defined as the element at position $M$ in the sorted order (using 1-based indexing). That is, if the merged sorted array is $A$, you need to output $A_{M}$.
inputFormat
The first line of input contains an integer T, the number of test cases. For each test case:
- The first line contains three space-separated integers: N, K, and M.
- The second line contains N space-separated integers representing the first sorted array.
- The third line contains K space-separated integers representing the second sorted array.
Read input from standard input (stdin).
outputFormat
For each test case, print a single line containing the M-th smallest element in the merged sorted array. Write the output to standard output (stdout).
## sample2
5 4 5
1 3 5 7 9
2 4 6 8
3 3 4
1 2 3
4 5 6
5
4
</p>