题面翻译
在将大部分钱花在各种项目上之后,Nadan 决定为他的软件开发人员买高品质的鞋子。 幸运的是,纳丹在地下室找到了 N 只左鞋和 M 只右鞋。 由于它们的来源不明,鞋子有各种尺寸。
Nadan 要求你尽可能多地配对鞋子(重要的是,配对完所有鞋子后不能选择新的一双)。 每双应由一只左鞋和一只右鞋组成。 在配对鞋子时,您应该确保将丑陋降至最低。 一对的丑被定义为所有双鞋之间鞋码的最大绝对差。
题目描述
After spending most of his money on various projects, Nadan decided to afford high quality shoes for his software developers. Luckily for Nadan, he found N left shoes and M right shoes in his basement. Since their origin is unknown, the shoes come in various sizes.
Nadan asked you to pair as many shoes as possible (it’s important that a new pair cannot be selected after pairing all the shoes). Each pair should consist of one left shoe and one right shoe. While pairing the shoes, you should make sure that the ugliness is minimized. The ugliness of one pairing is defined as the maximal absolute difference of the shoe sizes between all pairs of shoes.
输入格式
The first line contains two positive integers N and M (1 ≤ N, M ≤ 100 000), the number of left shoes and right shoes, in that order.
The second line contains N numbers Li (1≤Li≤109), the sizes of the left shoes.
The third line contains M numbers Ri (1≤Ri≤109), the sizes of the right shoes.
第一行包含两个正整数 N 和 M (1 ≤ N, M ≤ 100 000),依次是左鞋和右鞋的数量。
第二行包含 N 个数字 Li (1≤Li≤109),即左鞋的尺码。
第三行包含 M 个数字 Ri (1≤Ri≤109),即正确鞋子的尺码。
输出格式
Output the minimal ugliness between all possible shoe pairings.
样例 #1
样例输入 #1
2 3
2 3
1 2 3
样例输出 #1
0
样例 #2
样例输入 #2
4 3
2 39 41 45
39 42 46
样例输出 #2
1
样例 #3
样例输入 #3
5 5
7 6 1 2 10
9 11 6 3 12
样例输出 #3
4
SCORING
In test cases worth 20% of total points, it will hold that N = M.
In test cases worth additional 50% of total points, it will hold that N, M ≤ 5 000.
Clarification of the second sample test:
Nadan 有 4 左 3 右鞋子,最多可以获得 3 双。
一种可能的配对是:
39 - 46, 41 - 42, 45 - 39,但这种配对的丑陋是 7,因为第一对。 更好的配对是:39 - 39, 41 - 42, 45 - 46,丑陋等于 1,这是可以获得的最小可能丑陋。