#Lutece0066. Tom's Travel
Tom's Travel
Migrated from Lutece 66 Tom's Travel
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
Tom likes to travel and visit famous spots. One day he drives in a car to a strange country named BitLand and runs out of fuel, so he goes to a local gas station to fuel up his car. There are buckets of fuel on sale, each has a price and contains exactly liters of fuel, where k is specific to this bucket. In addition the worker at the station would only fuel up Tom's car if Tom buys exactly the amount of fuel equal to the volume of his car's tank.
Help Tom by giving him a fuel buying plan to minimize the amount of money he would spend.
Input
On the first line of the input is two integers and , number of buckets of fuel on sold, and the volume of Tom's tank in liters. Next lines each contain two numbers and , meaning this bucket contains exactly liters of fuel and costs dollars.
$0 \leq k \leq 30, 1 \leq N \leq 100000, 1 \leq M \leq 2000000000$
Prices are integers between and , inclusive.Output Output on a single line the minimum cost in dollars to buy exactly liters of fuel. If Tom can't fulfill the worker's requirement, output -1
instead.
-
means to the power of k, i.e. , , , , etc.
-
The volume of Tom's tank can be very huge since
Output
Output on a single line the minimum cost in dollars to buy exactly liters of fuel. If Tom can't fulfill the worker's requirement, output -1
instead.
Samples
3 5
0 1
1 2
2 3
4
Note
There are buckets of fuel and Tom must buy exactly liters of fuel. The first bucket contains liter of fuel and costs dollar. The second contains liters and costs dollars. The third contains liters and costs dollars. Tom can buy the first bucket and the third, for a total cost of dollars.
Resources
The 5th UESTC Programming Contest Preliminary