CF185E.Soap Time! - 2
NOI/NOI+/CTSC
通过率:0%
时间限制:6.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
想象笛卡尔坐标系。其中有 k 个互不相同的点,每个点代表一个地铁站。任意两个地铁站之间均可瞬间到达,即任意两个地铁站之间的换乘时间可视为零。你只允许在地铁站之间移动,也就是说,不允许在路径中途(即两站之间)离开地铁系统。
平面上有 n 个矮人,每个矮人用其坐标表示。这些矮人希望聚集在平面上某个整数坐标点,一起观看一部肥皂剧。为此,他们先选定一个集合点,然后同时出发向该点移动。每秒,一个矮人可以从点 (x,y) 移动到以下四个点之一:(x−1,y)、(x+1,y)、(x,y−1)、(x,y+1)。此外,矮人可以任意多次使用地铁(地铁可瞬间将矮人运送至任一地铁站)。矮人在移动过程中互不干扰(即所有矮人同时且独立地移动)。
请帮助这些矮人,求出他们全部聚集于同一点所需的最短时间。
输入格式
The first line contains two integers n and k (1 ≤ n ≤ 105; 0 ≤ k ≤ 105) — 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| ≤ 108) — 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| ≤ 108) — the coordinates of the t-th subway station. It is guaranteed that all subway stations are located at different points.
第一行包含两个整数 n 和 k(1≤n≤105;0≤k≤105),分别表示矮人的数量和地铁站的数量。
接下来的 n 行描述矮人的坐标。第 i 行包含两个以空格分隔的整数 xi 和 yi(∣xi∣,∣yi∣≤108),表示第 i 个矮人的坐标。保证所有矮人均位于互不相同的点上。
接下来的 k 行描述地铁站的坐标。第 t 行包含两个以空格分隔的整数 xt 和 yt(∣xt∣,∣yt∣≤108),表示第 t 个地铁站的坐标。保证所有地铁站均位于互不相同的点上。
输出格式
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
输入解题思路,AI测评打分。不知道怎么写?