Submit | All submissions | Best solutions | Back to list |
EI2122Q1ADAM2 - Matching |
Given the height of N men and M women. We need to form X pairs of one man and one woman. H is the maximum height difference of a pair, H = max({|pair.manHeight – pair.womanHeight| for X pairs}). What is the minimum possible value of H?
Input
- The first line contains three integers N, M, X (1 ≤ N ≤ 105).
- The second line contains N integers indicating the height of N men.
- The third line contains M integers indicating the height of M women.
Output
The minimum possible value of H.
Note: 50% test case: X = N = M
Sample
Input |
Output |
5 6 3 150 180 165 184 156 152 168 175 159 168 190 |
3 |
5 5 5 150 180 165 184 156 152 168 175 159 168 |
12 |