시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 128 MB | 1 | 1 | 1 | 100.000% |
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:
d((x1, y1), (x2, y2)) = |x1 - x2| + |y1 - y2|
Let us assume that every apple has fallen from the apple tree closest to it.
Write a program that:
1An English equivalent of this proverb is: 'Like father, like son' or 'Like mother, like daughter'.
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 2 · n integers from the range [0,108], separated with single spaces and denoting the pairs of coordinates of apple trees: x1 y1 x2 y2 ... xn yn. The third line of input contains 2 · m integers from the range [0,108], separated with single spaces and denoting the pairs of coordinates of apples: x'1 y'1 x'2 y'2 ... x'n y'n. 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.
3 4 0 2 2 0 2 2 1 1 2 1 2 3 1 4
1
Contest > Algorithmic Engagements > PA 2008 7-0번