#K49392. Minimum Number of Streetlights
Minimum Number of Streetlights
Minimum Number of Streetlights
In a city grid, there are m horizontal streets and n vertical streets. At each intersection a streetlight can be installed, and a single streetlight installed along, say, a street can cover all intersections on that street. However, due to budget constraints, the city must light up all intersections with the minimum number of streetlights. It turns out that the optimal strategy is to place streetlights on either all horizontal or all vertical streets – whichever is fewer. Therefore, the answer is \(\min(m, n)\).
Given two integers \(m\) and \(n\) representing the number of horizontal and vertical streets respectively, compute \(\min(m, n)\) which is the minimum number of streetlights required to cover the grid.
inputFormat
The input consists of two integers \(m\) and \(n\) (where \(1 \leq m, n \leq 1000\)) separated by space or newline. \(m\) represents the number of horizontal streets and \(n\) represents the number of vertical streets.
outputFormat
Output a single integer which is the minimum number of streetlights needed to cover all intersections in the grid.
## sample3 3
3