【例73.2】 数组的距离

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

说明

两个分别为nnmm的数组x[]x[]y[]y[]。从xx中任意取出一个元素x[i]x[i],然后从yy中任取一个元素y[j]y[j],他们的差的绝对值为x[i]y[i]∣x[i] - y[i]∣,一共有n×mn ×m 对这样的差值,其中最小的值称为数组的距离。
请你写一个程序求出数组的距离。

输入格式

输入第一行两个整数n,m(1≤n,m≤10^6)。
接下来一行输入 nn个整数表示数组 xx
接下来一行输入 mm 个整数表示数组 yy
输入的数组元素绝对值小于等于 10810^8

输出格式

输出一行一个整数表示两个数组的距离。

样例

5 5
1 2 3 4 5
6 7 8 9 10
1

2026.2.13

Not Attended
Status
Done
Rule
ACM/ICPC
Problem
23
Start at
2026-2-13 9:30
End at
2026-2-23 9:30
Duration
240 hour(s)
Host
Partic.
2