#ABC476D. 自动咖啡厅 / Automat
自动咖啡厅 / Automat
Problem Statement
In the Kingdom of AtCoder, two kinds of bills are in circulation: -dollar bills and -dollar bills.
At Company J's fully automated cafeteria in the kingdom, desserts and drinks are sold as products.
The company's fully automated cafeteria has a dessert vending machine that sells desserts, and a drink vending machine that sells drinks. The desserts are numbered through , and the drinks are numbered through .
Dessert costs dollars, and drink costs dollars.
As payment, the dessert vending machine accepts both -dollar bills and -dollar bills, but the drink vending machine accepts only -dollar bills. Both vending machines give change using only -dollar bills. You cannot buy two or more of the same product.
Takahashi came to Company J's fully automated cafeteria with -dollar bills and -dollar bills.
Among the combinations of products that he can buy with the bills he has, find the maximum number of products he can purchase.
Constraints
- ()
- ()
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Output the answer.
2 3 10
50 6
22 30
20 12 24
4
- By shopping as follows, Takahashi can buy four products.
- Pay two -dollar bills to buy drink . No change.
- Pay two -dollar bills to buy drink . The change is eight -dollar bills.
- Pay two -dollar bills and ten -dollar bills to buy dessert . No change.
- Pay twenty-two -dollar bills to buy dessert . No change.
He cannot buy more than four products, so the answer is .
1 7 67
677677677766666 0
777666777
20 12 24 67 67 67 67
1
- By shopping as follows, Takahashi can buy one product.
- Pay -dollar bills to buy dessert . The change is -dollar bills.
He cannot buy more than one product, so the answer is .
20 20 30
605776135 133105105
97363214 218434035 697895427 109255624 299037330 227873982 195540071 411713803 828357845 244535208 138059186 639510883 39844882 707397687 371274487 696536603 351588202 319490007 47121612 87169661
32256972 567982330 554885983 299718223 443859449 687952877 264684780 666659381 576335424 941894234 406248934 321334900 423472560 863738035 213143887 384834384 468161291 673106162 164648316 15903323
22
- Source: AtCoder ABC 476 D
相关
在下列比赛中: