Problem5967--ABC212 —— C - Min Difference

5967: ABC212 —— C - Min Difference

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 256 MiB

Description

You are given two sequences: $A=(A_1,\ A_2,\ …,\ A_N)$ consisting of $N$ positive integers, and $B=(B_1,\ …,\ B_M)$ consisting of $M$ positive integers.
Find the minimum difference of an element of $A$ and an element of $B$, that is, $\underset{1≤i≤N}{min}\ \underset{1≤j≤M}{min}\ |A_i−B_j|$.

Input

Input is given from Standard Input in the following format:
$N\ M$
$A_1\ A_2\ …\ A_N$
$B_1\ B_2\ …\ B_M$

Output

Print the answer.

Constraints

$1≤N,\ M≤2×10^5$
$1≤A_i≤10^9$
$1≤B_i≤10^9$
All values in input are integers.

Sample 1 Input

2 2
1 6
4 9

Sample 1 Output

2
Here is the difference for each of the four pair of an element of AA and an element of BB|14|=3|1−4|=3|19|=8|1−9|=8|64|=2|6−4|=2, and |69|=3|6−9|=3. We should print the minimum of these values, or 22.

Sample 2 Input

1 1
10
10

Sample 2 Output

0

Sample 3 Input

6 8
82 76 82 82 71 70
17 39 67 2 45 35 22 24

Sample 3 Output

3

HINT

题目来源:AtCoder ABC212 C题

Source/Category