CF1184C2.Heidi and the Turing Test (Medium)
提高+/省选-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
The Cybermen solved that first test much quicker than the Daleks. Luckily for us, the Daleks were angry (shocking!) and they destroyed some of the Cybermen.
After the fighting stopped, Heidi gave them another task to waste their time on.
There are n points on a plane. Given a radius r, find the maximum number of points that can be covered by an L1-ball with radius r.
An L1-ball with radius r and center (x0,y0) in a 2D-plane is defined as the set of points (x,y) such that the Manhattan distance between (x0,y0) and (x,y) is at most r.
Manhattan distance between (x0,y0) and (x,y) is defined as ∣x−x0∣+∣y−y0∣.
赛博人比戴立克更快地解决了第一项测试。幸运的是,戴立克因此大为恼怒(这可真令人震惊!),并摧毁了一些赛博人。
战斗结束后,海蒂又给他们布置了另一项任务,以消耗他们的时间。
平面上有 n 个点。给定半径 r,求一个半径为 r 的 L1-球最多能覆盖多少个点。
在二维平面上,以 (x0,y0) 为中心、半径为 r 的 L1-球定义为所有满足 (x0,y0) 与 (x,y) 之间的曼哈顿距离不超过 r 的点 (x,y) 所构成的集合。
(x0,y0) 与 (x,y) 之间的曼哈顿距离定义为 ∣x−x0∣+∣y−y0∣。
输入格式
The first line contains two integers n,r (1≤n≤300000,1≤r≤106), the number of points and the radius of the ball, respectively.
Each of the next n lines contains integers xi,yi (−106≤xi,yi≤106), describing the coordinates of the i-th point.
It is guaranteed, that all points are distinct.
第一行包含两个整数 n,r(1≤n≤300000,1≤r≤106),分别表示点的数量和球的半径。
接下来的 n 行中,每行包含两个整数 xi,yi(−106≤xi,yi≤106),描述第 i 个点的坐标。
保证所有点互不相同。
输出格式
Print one integer — the maximum number points that an L1-ball with radius r can cover.
输出一个整数——半径为 r 的 L1-球最多能覆盖的点数。
输入输出样例
输入#1
5 1 1 1 1 -1 -1 1 -1 -1 2 0
输出#1
3
输入#2
5 2 1 1 1 -1 -1 1 -1 -1 2 0
输出#2
5
说明/提示
In the first example, a ball centered at (1,0) covers the points (1,1), (1,−1), (2,0).
In the second example, a ball centered at (0,0) covers all the points.
Note that x0 and y0 need not be integer.
在第一个例子中,以 (1,0) 为球心的球覆盖了点 (1,1)、(1,−1) 和 (2,0)。
在第二个例子中,以 (0,0) 为球心的球覆盖了所有点。
注意:x0 和 y0 不必为整数。
输入解题思路,AI测评打分。不知道怎么写?