#P2918. [USACO08NOV] Buying Hay S
[USACO08NOV] Buying Hay S
Problem Description
Farmer John is running out of supplies and needs to purchase pounds of hay for his cows.
He knows hay suppliers conveniently numbered . Supplier i sells packages that contain pounds of hay at a cost of dollars. Each supplier has an unlimited number of packages available, and the packages must be bought whole.
Help FJ by finding the minimum cost necessary to purchase at least pounds of hay.
Input Format
* Line : Two space-separated integers: and
* Lines : Line contains two space-separated integers: and
Output Format
* Line : A single integer representing the minimum cost FJ needs to pay to obtain at least pounds of hay.
2 15
3 2
5 3
9
Hint
FJ can buy three packages from the second supplier for a total cost of .