A8477 | Soap Time! - 2
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
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.
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
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted