The Candy Store
Time limit3sMemory limit512 MB
With unlimited copies of each candy, find the maximum total calories obtainable with a given budget, where prices and the budget carry two decimal places.
- Level
Medium6 of 10
- Topics
- Dynamic programming, Implementation, Math, Greedy
- Solved
- No attempts yet
Problem
Sanggeun and Seonyeong were walking together when they passed a candy store. Sanggeun suddenly began lecturing about how unhealthy candy is, and an annoyed Seonyeong challenged him to a bet over who could ruin their health more. Sanggeun accepted on the spot.
The two of them enter the store with the exact same amount of money and buy candy. Whoever ends up with the greater total number of calories wins the bet.
Pretending to head to the restroom, Sanggeun slipped out, opened his laptop, and connected to the store's system, which lists the price and calorie count of every candy currently on sale. Each kind of candy is effectively unlimited in stock, so you may buy as many of the same kind as you like. Candy cannot be split, so the quantity of each kind must be a non-negative integer.
Given the price and calorie count of every candy in the store, write a program that finds the maximum total calories you can buy with the money you have.
Input
The input consists of several test cases.
The first line of each test case contains the number of candy kinds in the store and the amount of money that Sanggeun has. (, ) is always given to exactly two decimal places.
Each of the next lines contains a candy's calorie count and price . (, ) is always an integer, and is always given to exactly two decimal places.
The last line of the input is 0 0.00 and must not be processed.
Output
For each test case, print on its own line the maximum total calories that can be bought with the money .