#K63117. Minimum Irrigation Systems
Minimum Irrigation Systems
Minimum Irrigation Systems
Given a garden represented as an R × C grid, each cell can be irrigated by an irrigation system that covers a 2 × 2 subgrid. An irrigation system installed at the top-left cell of a subgrid will cover the cells at positions \((i, j)\), \((i, j+1)\), \((i+1, j)\), and \((i+1, j+1)\) (if they exist within the grid). The task is to determine the minimum number of irrigation systems required to cover the entire garden.
The answer can be computed using the formula
$$\left\lceil\frac{R}{2}\right\rceil \times \left\lceil\frac{C}{2}\right\rceil $$Note that although the garden grid may contain water requirement values for plants, these values do not affect the placement of the irrigation systems.
inputFormat
The first line contains two integers \(R\) and \(C\) separated by a space, representing the number of rows and columns of the garden grid, respectively.
The following \(R\) lines each contain \(C\) integers separated by spaces. These integers represent the water requirements of the plants, but they do not affect the solution.
Input is taken from standard input (stdin).
outputFormat
Output a single integer representing the minimum number of irrigation systems required to cover the garden. The output should be written to standard output (stdout).
## sample4 4
1 2 2 1
2 2 3 2
3 3 3 3
1 2 2 1
4