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 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 ∣x−x0∣+∣y−y0∣|x - x_0| + |y - y_0|.

赛博人比戴立克更快地解决了第一项测试。幸运的是,戴立克因此大为恼怒(这可真令人震惊!),并摧毁了一些赛博人。

战斗结束后,海蒂又给他们布置了另一项任务,以消耗他们的时间。

平面上有 nn 个点。给定半径 rr,求一个半径为 rr 的 L1L^1-球最多能覆盖多少个点。

在二维平面上,以 (x0,y0)(x_0, y_0) 为中心、半径为 rr 的 L1L^1-球定义为所有满足 (x0,y0)(x_0, y_0) 与 (x,y)(x, y) 之间的曼哈顿距离不超过 rr 的点 (x,y)(x, y) 所构成的集合。

(x0,y0)(x_0, y_0) 与 (x,y)(x, y) 之间的曼哈顿距离定义为 ∣x−x0∣+∣y−y0∣|x - x_0| + |y - y_0|。

输入格式

The first line contains two integers n,rn, r (1≤n≤300 000,1≤r≤1061 \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 (−106≤xi,yi≤106-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.

第一行包含两个整数 n,rn, r(1≤n≤300 0001 \le n \le 300\,000,1≤r≤1061 \le r \le 10^6),分别表示点的数量和球的半径。

接下来的 nn 行中,每行包含两个整数 xi,yix_i, y_i(−106≤xi,yi≤106-10^6 \leq x_i, y_i \leq 10^6),描述第 ii 个点的坐标。

保证所有点互不相同。

输出格式

Print one integer — the maximum number points that an L1L^1-ball with radius rr can cover.

输出一个整数——半径为 rr 的 L1L^1-球最多能覆盖的点数。

输入输出样例

  • 输入#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.

在第一个例子中,以 (1,0)(1, 0) 为球心的球覆盖了点 (1,1)(1, 1)、(1,−1)(1, -1) 和 (2,0)(2, 0)。

在第二个例子中,以 (0,0)(0, 0) 为球心的球覆盖了所有点。

注意:x0x_0 和 y0y_0 不必为整数。

输入解题思路,AI测评打分。不知道怎么写?

首页