#P2376. [USACO05OCT] Allowance S / [USACO09OCT] Allowance G
[USACO05OCT] Allowance S / [USACO09OCT] Allowance G
Description
As a reward for setting a milk production record, Farmer John decides to give Bessie a weekly allowance.
FJ has some coins, with different denominations. Each denomination divides all larger denominations.
Using the given collection of coins, he wants to give Bessie at least each week. Please compute the maximum number of weeks he can make such payments.
Input Format
Line : Two space-separated integers: and .
Lines to : Each line contains two integers describing one coin denomination: the coin value and the number of coins of that denomination .
Output Format
Line : A single integer, the maximum number of weeks he can pay an allowance of at least .
3 6
10 1
1 100
5 120
111
Hint
FJ can overpay Bessie with the one -cent coin for week, then pay Bessie two -cent coins for weeks and then pay Bessie one -cent coin and one -cent coin for weeks.
京公网安备 11011102002149号