The Candy Store

Time limit3sMemory limit512 MB

Summary
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 nn in the store and the amount of money mm that Sanggeun has. (1≤n≤5 0001 \le n \le 5\,000, 0.01≤m≤100.000.01 \le m \le 100.00) mm is always given to exactly two decimal places.

Each of the next nn lines contains a candy's calorie count cc and price pp. (1≤c≤5 0001 \le c \le 5\,000, 0.01≤p≤100.000.01 \le p \le 100.00) cc is always an integer, and pp 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 mm.

Examples1

  1. Example 1

    Input
    2 8.00
    700 7.00
    199 2.00
    3 8.00
    700 7.00
    299 3.00
    499 5.00
    0 0.00
    
    Expected output
    796
    798