#K79182. Potion Duration Maximization
Potion Duration Maximization
Potion Duration Maximization
You are given several test cases. In each test case, you have a limited budget B and a list of potion types, where each potion is described by its cost and its duration.
Your task is to maximize the total duration of the potion effects you can purchase. You are allowed to purchase an arbitrary number of each potion type. Formally, for each test case, if you purchase quantityi of the i-th potion (which has cost ci and duration di), you want to maximize:
\(\sum_{i} quantity_i \times d_i\)
subject to the constraint:
\(\sum_{i} quantity_i \times c_i \le B\)
The input ends with a line containing "0 0", which should not be processed.
inputFormat
The input consists of multiple test cases. Each test case begins with a line containing two integers N and B, where:
- N is the number of potion types.
- B is the available budget.
This is followed by N lines, each containing two space-separated integers representing the cost and the duration of a potion type.
The input terminates with a line containing "0 0", which should not be processed.
outputFormat
For each test case, print a single line containing the maximum total duration that can be achieved using the available budget.
## sample3 50
10 5
20 10
30 15
2 12
5 7
6 8
0 0
25
14
</p>