#C11913. Maximum Cooperative Group of Towers

    ID: 41282 Type: Default 1000ms 256MiB

Maximum Cooperative Group of Towers

Maximum Cooperative Group of Towers

You are given n towers on a grid. Each tower is defined by three numbers x, y, and s, where (x, y) are the coordinates of the center of the tower and s is the length of the side of the square-shaped area the tower covers. The square covers the area from x - s/2 to x + s/2 horizontally and from y - s/2 to y + s/2 vertically.

Two towers are considered directly connected if their square areas overlap or touch. Connectivity is transitive – that is, if tower A is connected to tower B and tower B is connected to tower C, then towers A and C are in the same cooperative group.

Your task is to determine the maximum number of towers that can form a single cooperative group.

The overlapping condition between two towers labeled 1 and 2 can be expressed in LaTeX as follows:

$$\text{Let } half_1 = \frac{s_1}{2}, \quad half_2 = \frac{s_2}{2} \\ \text{Tower 1 covers } [x_1-half_1,\, x_1+half_1] \times [y_1-half_1,\, y_1+half_1] \\ \text{Tower 2 covers } [x_2-half_2,\, x_2+half_2] \times [y_2-half_2,\, y_2+half_2] \\ \text{They overlap if } \neg (x_1+half_1 < x_2-half_2 \text{ or } x_2+half_2 < x_1-half_1 \text{ or } y_1+half_1 < y_2-half_2 \text{ or } y_2+half_2 < y_1-half_1). $$

inputFormat

The input is given via stdin and has the following format:

  • The first line contains a single integer n — the number of towers.
  • Each of the next n lines contains three numbers: x, y, and s, where (x, y) represents the center coordinates and s represents the side length of the tower's coverage area.

All numbers are space-separated.

outputFormat

Output the size of the largest cooperative group as a single integer to stdout.

## sample
5
0 0 2
3 0 2
1 1 2
4 4 2
5 5 2
3