시간 제한메모리 제한제출정답맞힌 사람정답 비율
0.4 초 1024 MB59161428.571%

문제

Deni and Bob wonder how to spend the free time between their classes. They come up with the following. Deni marked N points on a graph paper. It is possible that some of the points are marked on the same place but they are still counted as different points. The graph paper is rectangular in shape with width d1 and height d2, and on which the lower left vertex is assumed as a point with coordinates (0, 0), and the upper right vertex - with coordinates (d1, d2). Bob then came up with the numbers w and h, and together they began to search for a rectangle of width w and height h, with sides parallel to the sides of the graph paper and containing as many points as possible (including points on the sides of the sought rectangle). The big problem, however, was that they were not sure if they had found the maximum possible number of points that can be contained in such a rectangle. Deni knows that you are a very good programmer, so she asks you to write a program rectpoints.cpp that for given N points and sizes w and h for a rectangle, finds the maximum number of points that are contained in a rectangle of that size.

입력

From the first line of the standard input, your program reads three integers N, w and h - the number of points marked on the graph paper and the sizes of the rectangle they are looking for. From each of the next N lines, your program reads two integers x and y, separated by a space - the two coordinates of each of the marked points on the graph paper.

출력

On a single line, your program prints an integer equal to the maximum number of points that can be contained in a rectangle with sizes w and h, which has sides parallel to the sides of the graph paper.

제한

  • 1 ≤ N ≤ 105
  • 1 ≤ x, y, w, h ≤ 108

서브태스크

번호배점제한
111

N ≤ 102, x, y, w, h ≤ 102

223

N ≤ 103, x, y, w, h ≤ 108

312

N ≤ 105, x, y, w, h ≤ 103, There is an optimal sought rectangle, for which one of the points is its upper right vertex

419

N ≤ 105, x, y, w, h ≤ 105, There is an optimal sought rectangle, for which one of the points is its upper right vertex

526

N ≤ 105, x, y, w, h ≤ 105

69

N ≤ 105, x, y, w, h ≤ 108

예제 입력 1

6 2 3
1 1
3 1
2 2
3 3
5 3
3 5

예제 출력 1

4

Аn optimal rectangle is the one with the upper right vertex at the point (3, 3). Its coordinates of the lower left vertex are (1, 0), of the lower right vertex - (3, 0) and of the upper left vertex - (1, 3). It contains the points (1, 1); (2, 2); (3, 1); (3, 3). Note that this example satisfies the additional constraints of the 4th and 5th subtasks.

예제 입력 2

10 8 8
8 9
20 14
3 9
7 8
3 4
7 8
10 19
6 11
5 10
8 2

예제 출력 2

7

An optimal rectangle is the one with the upper right vertex at the point (9, 11) and it contains the points (8, 9); (3, 9); (7, 8); (3, 4); (7, 8); (6, 11) and (5, 10). Note that there is a repeating point (7, 8) and it is counted 2 times (as many times as it occurs). Unlike the previous example, there is no optimal solution in which one of the points is the upper right vertex of an optimal rectangle.

채점 및 기타 정보

  • 예제는 채점하지 않는다.