P4876 [USACO14MAR] The Lazy Cow G

Description

It's a hot summer day, and Bessie the cow is feeling quite lazy. She wants to locate herself at a position in her field so that she can reach as much delicious grass as possible within only a short distance. There are $N$ patches of grass $(1

Input Format

* Line 1: The integers $N$ and $K$. * Lines 2..1+N: Line $i+1$ describes the $ith$ patch of grass using 3 integers: $g_i, x_i, y_i.$

Output Format

* Line 1: The maximum amount of grass Bessie can reach within $K$ steps, if she locates herself at the best possible initial position.

Explanation/Hint

INPUT DETAILS: Bessie is willing to take at most 3 steps from her initial position. There are 4 patches of grass. The first contains 7 units of grass and is located at position $(8,6)$, and so on. OUTPUT DETAILS: By locating herself at $(3,0)$, the grass at positions $(0,0)$, $(6,0)$, and $(4,2)$ is all within $K$ units of distance.