CF1184C2.Heidi and the Turing Test (Medium)
普及/提高-
通过率:0%
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∣ .
输入格式
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.
输出格式
Print one integer — the maximum number points that an L1 -ball with radius r can cover.
输入输出样例
输入#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.