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 nn points on a plane. Given a radius rr , find the maximum number of points that can be covered by an L1L^1 -ball with radius rr .

An L1L^1 -ball with radius rr and center (x0,y0)(x_0, y_0) in a 2D-plane is defined as the set of points (x,y)(x, y) such that the Manhattan distance between (x0,y0)(x_0, y_0) and (x,y)(x, y) is at most rr .

Manhattan distance between (x0,y0)(x_0, y_0) and (x,y)(x, y) is defined as xx0+yy0|x - x_0| + |y - y_0| .

输入格式

The first line contains two integers n,rn, r ( 1n300000,1r1061 \le n \le 300\,000, 1 \le r \le 10^6 ), the number of points and the radius of the ball, respectively.

Each of the next nn lines contains integers xi,yix_i, y_i ( 106xi,yi106-10^6 \leq x_i, y_i \leq 10^6 ), describing the coordinates of the ii -th point.

It is guaranteed, that all points are distinct.

输出格式

Print one integer — the maximum number points that an L1L^1 -ball with radius rr 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)(1, 0) covers the points (1,1)(1, 1) , (1,1)(1, -1) , (2,0)(2, 0) .

In the second example, a ball centered at (0,0)(0, 0) covers all the points.

Note that x0x_0 and y0y_0 need not be integer.

首页