#C7418. Minimum Streetlights
Minimum Streetlights
Minimum Streetlights
You are given a grid of size \(H \times W\). Each cell in the grid represents an intersection, and you need to install streetlights such that the entire grid is illuminated. After careful observation, you realize that the optimal strategy is to install streetlights along a line (either a row or a column) such that every intersection gets illuminated. The minimum number of streetlights required turns out to be \(\min(H, W)\).
Example:
For a grid of size 3 by 4, the answer is \(\min(3, 4) = 3\).
For a grid of size 5 by 5, the answer is \(\min(5, 5) = 5\).
inputFormat
The input consists of two space-separated integers H and W (\(1 \leq H, W \leq 10^5\)), representing the dimensions of the grid.
outputFormat
Output a single integer — the minimum number of streetlights needed to fully illuminate the grid.
## sample1 1
1