#K15371. Minimum Watering Can Placements

    ID: 24342 Type: Default 1000ms 256MiB

Minimum Watering Can Placements

Minimum Watering Can Placements

Given a rectangular garden with flowers planted at specific coordinates, determine the minimum number of placements of a watering can required to water all the flowers. The watering can, when placed with its top-left corner at \((x, y)\), covers a rectangular region of size \(a \times b\). In particular, it covers all cells \((i,j)\) satisfying:

[ x \le i \le x+a-1 \quad \text{and} \quad y \le j \le y+b-1 ]

You are provided with the number of flowers and their coordinates, along with the dimensions of the watering can. Your task is to determine the minimum number of placements needed so that every flower is covered by at least one placement. This problem can be approached using a greedy strategy.

inputFormat

The input is read from stdin and has the following format:

  • The first line contains four integers \(n\), \(m\), \(a\), and \(b\), where \(n\) is the size of the garden (which may not be used directly in the solution), \(m\) is the number of flowers, and \(a\) and \(b\) are the height and width of the watering can respectively.
  • Each of the next \(m\) lines contains two integers representing the coordinates of a flower.

outputFormat

Output a single integer to stdout which is the minimum number of placements needed to cover all the flowers.

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

</p>