| UDESC Selection Contest 2026-1 |
|---|
| Закончено |
Dudu Uga is a fearless caveman who found $$$N$$$ dinosaur eggs scattered on the ground. However, thanks to his infinite wisdom, he knew that the location was vulnerable to attacks from oviraptors*. So, Dudu decided to build a fence to keep the eggs safe.
Each egg has negligible volume (after all, they belong to Oculudentavis khaungraae, the smallest known dinosaur species) and Dudu only cares about their position, which can be represented by their integer coordinates $$$(x, y)$$$ in the Cartesian plane. As time is short, Dudu was only able to gather enough material to build a square fence of side $$$L$$$. Considering that eggs on the perimeter of the fence are also protected and that Dudu can build the fence anywhere in the plane, what is the maximum number of eggs he can protect?
The first line contains two integers, $$$N$$$ $$$(1 \le N \le 2 \cdot 10^5)$$$ and $$$L$$$ $$$(1 \le L \le 2 \cdot 10^5)$$$, representing the number of eggs and the side of the square, respectively.
The next $$$N$$$ lines contain two integers $$$x_i$$$ and $$$y_i$$$ $$$(0 \le x_i, y_i \le 2 \cdot 10^5)$$$, the coordinates of the $$$i$$$-th egg.
Print a single integer, the maximum number of eggs Dudu can protect by building the fence anywhere in the plane.
4 21 30 22 51 1
3
10 41 25 39 45 12 26 77 63 10 22 3
6
(*) Little did Dudu know that oviraptors, ironically, did not eat eggs.
| Название |
|---|


