#5178. Manhattan Multifocal Ellipse

0
    ID: 5178 传统题 2000ms 1024MiB 尝试: 0 已通过: 0 难度: 4 上传者: 标签>AtCoderabc366EGESP 5级前缀和双指针排序

Manhattan Multifocal Ellipse

Manhattan Multifocal Ellipse

题目描述

You are given NN points (x1,y1),(x2,y2),…,(xN,yN)(x_1, y_1), (x_2, y_2), \dots, (x_N, y_N) on a two-dimensional plane, and a non-negative integer DD. Find the number of integer pairs (x,y)(x, y) such that $\displaystyle \sum_{i=1}^N (|x-x_i|+|y-y_i|) \leq D$.

输入格式

The input is given from Standard Input in the following format: NN DD x1x_1 y1y_1 x2x_2 y2y_2 ⋮\vdots xNx_N yNy_N

输出格式

Print the answer.

2 3
0 0
1 0
8
2 0
0 0
2 0
0
6 100
9 -6
10 -1
2 10
-1 7
-7 5
-1 -4
419

提示

1≤N≤2×1051 \leq N \leq 2 \times 10^5 0≤D≤1060 \leq D \leq 10^6 −106≤xi,yi≤106-10^6 \leq x_i, y_i \leq 10^6 (xi,yi)≠(xj,yj)(x_i, y_i) \neq (x_j, y_j) for i≠ji \neq j. All input values are integers.The following figure visualizes the input and the answer for Sample 11. The blue points represent the input. The blue and red points, eight in total, satisfy the condition in the statement.

标签: AtCoder|abc366E

来源

AtCoder|abc366E