#P11510. Minimum Container Weight
Minimum Container Weight
Minimum Container Weight
A regional sorting center is developing an automated mail distribution system. At a postal network outlet, packages are received with an integer weight in the range \(1\) to \(k\) kilograms. The packages are placed one by one into a bag. As soon as the cumulative weight in the bag reaches or exceeds \(x\) kilograms, the bag is dispatched to a city postal center where it is placed into a container. Similarly, whenever adding a bag to the container causes its total weight to reach or exceed \(y\) kilograms, the container is dispatched to the district sorting center for final delivery.
Your task is to compute the minimum possible weight of a container when it is dispatched to the district sorting center.
Note: You may choose the package weights optimally (each package weight is an integer between \(1\) and \(k\)) to achieve the minimum possible weight. It turns out that the optimal strategy is to pack each bag with a total weight exactly equal to \(x\) kilograms (if possible), and then the container's weight becomes \(x \times n\) where \(n\) is the minimum number of bags required such that \(n \times x \geq y\). In other words, the answer is given by \(\lceil \frac{y}{x} \rceil \times x\).
inputFormat
The input consists of a single line containing three space-separated integers:
- k: the maximum weight of a package (in kilograms)
- x: the minimum total weight for a bag to be dispatched (in kilograms)
- y: the minimum total weight for a container to be dispatched (in kilograms)
outputFormat
Output a single integer, representing the minimum possible weight of a container when it is delivered to the district sorting center.
sample
10 5 12
15