#P10056. Maximizing the Water Volume in a Cup

    ID: 12036 Type: Default 1000ms 256MiB

Maximizing the Water Volume in a Cup

Maximizing the Water Volume in a Cup

You are given n cups. Each cup has a capacity of \(a\) and initially contains \(b\) units of water. You are allowed to perform an arbitrary number of operations. In each operation, you can choose any two cups and pour all the water from one cup into the other cup. However, during the pouring process the target cup must not overflow, i.e. after pouring, the water in the target cup does not exceed its capacity \(a\). If the operation would cause an overflow, it cannot be performed.

Your task is to determine the maximum amount of water that can be contained in any one cup after performing a sequence of valid operations.

Note: Each pouring operation moves all the water from the source cup into the target cup, and partial pouring is not allowed.

inputFormat

The input consists of a single line containing three integers \(n\), \(a\), and \(b\), where \(n\) is the number of cups, \(a\) is the capacity of each cup, and \(b\) is the initial amount of water in each cup.

\(1 \leq n \leq 10^9, \; 0 \leq b \leq a \leq 10^9\)

outputFormat

Output a single integer representing the maximum water volume that can be achieved in any cup by performing a sequence of valid operations.

sample

5 10 3
9