300982: CF185E. Soap Time! - 2

Memory Limit:256 MB Time Limit:6 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Soap Time! - 2

题目描述

Imagine the Cartesian coordinate system. There are $ k $ different points containing subway stations. One can get from any subway station to any one instantly. That is, the duration of the transfer between any two subway stations can be considered equal to zero. You are allowed to travel only between subway stations, that is, you are not allowed to leave the subway somewhere in the middle of your path, in-between the stations. There are $ n $ dwarves, they are represented by their coordinates on the plane. The dwarves want to come together and watch a soap opera at some integer point on the plane. For that, they choose the gathering point and start moving towards it simultaneously. In one second a dwarf can move from point $ (x,y) $ to one of the following points: $ (x-1,y) $ , $ (x+1,y) $ , $ (x,y-1) $ , $ (x,y+1) $ . Besides, the dwarves can use the subway as many times as they want (the subway transfers the dwarves instantly). The dwarves do not interfere with each other as they move (that is, the dwarves move simultaneously and independently from each other). Help the dwarves and find the minimum time they need to gather at one point.

输入输出格式

输入格式


The first line contains two integers $ n $ and $ k $ $ (1<=n<=10^{5}; 0<=k<=10^{5}) $ — the number of dwarves and the number of subway stations, correspondingly. The next $ n $ lines contain the coordinates of the dwarves. The $ i $ -th line contains two space-separated integers $ x_{i} $ and $ y_{i} $ ( $ |x_{i}|,|y_{i}|<=10^{8} $ ) — the coordinates of the $ i $ -th dwarf. It is guaranteed that all dwarves are located at different points. The next $ k $ lines contain the coordinates of the subway stations. The $ t $ -th line contains two space-separated integers $ x_{t} $ and $ y_{t} $ ( $ |x_{t}|,|y_{t}|<=10^{8} $ ) — the coordinates of the $ t $ -th subway station. It is guaranteed that all subway stations are located at different points.

输出格式


Print a single number — the minimum time, in which all dwarves can gather together at one point to watch the soap.

输入输出样例

输入样例 #1

1 0
2 -2

输出样例 #1

0

输入样例 #2

2 2
5 -3
-4 -5
-4 0
-3 -2

输出样例 #2

6

Input

题意翻译

在一个二维直角坐标系中,有 $k$ 个不同的点为地铁站。人们可以瞬间从任何地铁站到达任何另外一个地铁站,也就是说,任意两个地铁站之间换乘的时间可以认为是零。你只能在地铁站之间旅行,即你不能在你乘坐地铁的过程中离开地铁。 在这个坐标系中有 $n$ 个矮人,他们的初始坐标为 $(x_i, y_i)$ 。 矮人们想聚在一起,在平面的某个点看肥皂剧;在一秒钟内,矮人可以从点 $(x, y)$ 移动到以下的任意一个点:$(x − 1, y)$ , $(x + 1, y)$ , $(x, y − 1)$ , $(x, y + 1)$。此外,矮人可以无限次乘坐地铁,且矮人在移动时不会互相干扰。 你需要找到矮人们聚集在一处所需的最短时间。

加入题单

算法标签: