Under construction

Still being built. Things may change

Donut-shaped Enclosure

Time limit3sMemory limit1024 MB

Summary
Place a Chebyshev-distance donut with inner radius L and outer radius R at a lattice center to maximize the total weight of covered points.
Level

Hard8 of 10

Topics
Geometry, Prefix sum, Sorting, Math
Solved
No attempts yet

Problem

The distance system usually used in the two-dimensional plane is Euclidean distance. In Euclidean distance, the distance between two points (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2) is written as (x1−x2)2+(y1−y2)2\sqrt{(x_1 - x_2)^2 + (y_1 - y_2)^2}.

This problem deals with Chebyshev distance instead of Euclidean distance. In Chebyshev distance, the distance between (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2) is written as max⁡(∣x1−x2∣,∣y1−y2∣)\max{(|x_1 - x_2|, |y_1 - y_2|)}.

For a given distance system, a circle of radius rr is the set of points (x,y)(x,y) whose distance to a specific point (xc,yc)(x_c, y_c) is rr. The shape of a circle depends on which distance system is used. As (Figure 1) shows, under Euclidean distance it is the circular shape we usually know, and under Chebyshev distance a square with side length 2r2r becomes the circle.

Figure 1 : Circles under Euclidean distance and Chebyshev distance

Also, for a given distance system, a donut with inner radius ll and outer radius rr is the set of points (x,y)(x,y) whose distance to a specific point (xc,yc)(x_c, y_c) is at least ll and at most rr.

In (Figure 2), the left side is a donut under Euclidean distance and the right side is a donut under Chebyshev distance. The gray region is the region included in the donut.

Figure 2 : Donuts under Euclidean distance and Chebyshev distance

Bumsoo is playing with NN points P1P_1, P2P_2, ⋯\cdots, PNP_N and a donut under Chebyshev distance whose inner radius is LL and outer radius is RR. PiP_i is located at (xi,yi)(x_i, y_i), and Bumsoo can freely change the position of the donut's center as long as he keeps the center's coordinates on a lattice point. If PiP_i lies in the donut region, Bumsoo is forced to gain SiS_i points, and if it does not lie in the donut region, he gains no points. Write a program that finds the maximum score Bumsoo can gain.

Input

The first line of the input gives three integers NN, LL, RR (1≤N≤1051 ≤ N ≤ 10^5, 1≤L≤R≤1091 ≤ L ≤ R ≤ 10^9), separated by a single space.

The ii-th of the following NN lines gives xix_i, yiy_i, SiS_i (−109≤xi,yi≤109-10^9 ≤ x_i, y_i ≤ 10^9, −104≤Si≤104-10^4 ≤ S_i ≤ 10^4), separated by a single space. Multiple points may be at the same position.

Output

On the first line, print the maximum score Bumsoo can gain.

Hint

For the first sample, it is enough to put the donut's center at (1,0)(1,0) or (−1,0)(-1,0).

For the second sample, the donut has become too large, so the best choice is to include one of the 11s while avoiding the −100-100s.

Examples2

  1. Example 1

    Input
    4 1 1
    0 1 1
    0 -1 1
    1 0 -100
    -1 0 -100
    
    Expected output
    2
    
  2. Example 2

    Input
    4 1 2
    0 1 1
    0 -1 1
    1 0 -100
    -1 0 -100
    
    Expected output
    1