In the event of technical difficulties with Szkopuł, please contact us via email at [email protected].
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. Positions of apple trees and apples can be identified with points on a plane. The distances between points are defined by Manhattan metric:
Let us 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 pairs of coordinates of apple trees: . The third line of input contains integers from the range , separated with single spaces and denoting the pairs of coordinates of apples: . We treat both apple trees and apples as points on a plane; 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 4 0 2 2 0 2 2 1 1 2 1 2 3 1 4
the correct result is:
Task author: Jakub Radoszewski.