TrafficTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 1703 Accepted Submission(s): 375
Problem Description Avin is observing the cars at a crossroads. He finds that there are n cars running in the east-west direction with the i-th car passing the intersection at time ai . There are another m cars running in the north-south direction with the i-th car passing the intersection at time bi . If two cars passing the intersections at the same time, a traffic crash occurs. In order to achieve world peace and harmony, all the cars running in the north-south direction wait the same amount of integral time so that no two cars bump. You are asked the minimum waiting time.
Input The first line contains two integers n and m (1 ¡Ü n, m ¡Ü 1, 000). The second line contains n distinct integers ai (1 ¡Ü ai ¡Ü 1, 000). The third line contains m distinct integers bi (1 ¡Ü bi ¡Ü 1, 000).
Output Print a non-negative integer denoting the minimum waiting time.
Sample Input
Sample Output Statistic | Submit | Clarifications | Back
|