#C7173. Marathon Water Stations
Marathon Water Stations
Marathon Water Stations
The marathon organizers need to install water stations along a race route of length \(M\) meters. Given \(N\) available water stations, your task is to determine the minimized maximum distance that any participant will have to cover without encountering a water station, if the stations are placed in an optimal manner. In other words, partition the route into \(N\) segments as evenly as possible so that the largest segment length is minimized.
Mathematically, the answer is \(\lceil \frac{M}{N} \rceil\), which can also be computed using the formula:
[ \text{result} = \frac{M + N - 1}{N} \quad \text{(using integer division)} ]
For example, if there are 4 water stations and the length of the route is 10 meters, the minimized maximum distance is 3 meters.
inputFormat
The input is provided via standard input (stdin) and consists of two space-separated integers:
- N: the number of water stations.
- M: the total length of the marathon route in meters.
You may assume that both \(N\) and \(M\) are positive integers.
outputFormat
Output a single integer to standard output (stdout). This integer is the minimized maximum distance any participant would need to cover without encountering a water station, i.e. \(\lceil \frac{M}{N} \rceil\).
## sample4 10
3