QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 64 MB Total points: 100

#11044. Near

الإحصائيات

A known Polish proverb is: 'The apple always falls near the apple tree'^{1}. Your task is to check this proverb experimentally. For simplicity let us assume that both apple trees and apples stand in one line, so their positions can be described by a single coordinate. Let us also assume that every apple has fallen from the apple tree closest to it.

Write a program that:

  • reads from the standard input a description of positions of apple trees and apples,
  • computes the smallest distance between an apple and its apple tree,
  • writes the result to the standard output.

^{1}An English equivalent of this proverb is: 'Like father, like son' or 'Like mother, like daughter'.

Input Format

The first line of input contains two integers $ n $ and $ m $ ($1 ≤ n, m ≤ 100\,000$), separated with a single space and denoting the number of apple trees and the number of apples. The second line of input contains $ n $ integers from the range $[0,10^{8}]$, separated with single spaces and denoting the coordinates of apple trees. The third line of input contains $ m $ integers from the range $[0,10^{8}]$, separated with single spaces and denoting the coordinates of apples. We treat both apple trees and apples as points on a line; there can be multiple apple trees and multiple apples in one point.

Output Format

The first and only line of output should contain the smallest distance between an apple and its apple tree.

Example

Input

3 5
10 1 4
2 2 5 7 8

Output

1

Discussions

About Discussions

The discussion section is only for posting: Editorials, General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues. Submitting multiple issues may cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.