In the event of technical difficulties with Szkopuł, please contact us via email at szkopul@fri.edu.pl.
If you would like to talk about tasks, solutions or technical problems, please visit our Discord servers. They are moderated by the community, but members of the support team are also active there.
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:
The first line of input contains two integers and
(
), separated with a single space and denoting
the number of apple trees and the number of apples.
The second line of input contains
integers from the range
, separated with single spaces and denoting the coordinates
of apple trees.
The third line of input contains
integers from the range
, 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.
The first and only line of output should contain the smallest distance between an apple and its apple tree.
For the input data:
3 5 10 1 4 2 2 5 7 8
the correct result is:
1
Task author: Jakub Radoszewski.