NOI Contest Archive

Archive / 2021 / Final Round — Day 1

Mango Plantation

Medium · National Olympiad in Informatics Sri Lanka 2021 - Day 1

Mango trees grow in different sizes but each gives equal produce. And they need sun as well as wind 🤷‍♂️ to grow. You have a rectangular plot of land. The wind is flowing from north to south (along y axis).

Your workers have spread the mango seeds all over the place. And the seeds have germinated already (so you can’t remove and plant them somewhere else). They have used up all N seeds. You know the location of each seed (xi, yi) and the size it would grow into (their radius: ri). The trees grow into a perfect semi-spherical shape of radius ri.

You need to remove seeds so that the remaining plants can grow, without overlapping and with full exposure to wind (full corridor of width equal to the diameter of the tree along x-axis should be open for each tree). You also need to remove trees that would grow beyond your plot of land.

Calculate the maximum number of seeds that can be kept.

Input Format

First line contains 3 integers, N, W and H, the number of seeds planted, width and height of the plot of land.
Following N lines each contain three integers, xi, yi and ri. The location of the seeds and radius they will grow into.

Output Format

The maximum number of seeds that can be kept.

Constraints

Subtasks

  1. (50 points)
    • 1 \(\leq\) N \(\leq\) 5000
    • 1 \(\leq\) W, H \(<\) 106
    • 1 \(\leq\) R \(<\) 106
  2. (50 points)
    • No additional constraints.

Limits

Sample Input 0

6 10 10
0 0 5
2 5 1
8 8 2
3 9 2
4 4 3
4 5 1

Sample Output 0

3