atcoder#DIVERTA20192D. Squirrel Merchant
Squirrel Merchant
Score : points
Problem Statement
The squirrel Chokudai has acorns. One day, he decides to do some trades in multiple precious metal exchanges to make more acorns.
His plan is as follows:
- Get out of the nest with acorns in his hands.
- Go to Exchange and do some trades.
- Go to Exchange and do some trades.
- Go to Exchange and do some trades.
- Go back to the nest.
In Exchange , he can perform the following operations any integer number of times (possibly zero) in any order:
- Lose acorns and gain gram of gold.
- Gain acorns and lose gram of gold.
- Lose acorns and gain gram of silver.
- Gain acorns and lose gram of silver.
- Lose acorns and gain gram of bronze.
- Gain acorns and lose gram of bronze.
Naturally, he cannot perform an operation that would leave him with a negative amount of acorns, gold, silver, or bronze.
What is the maximum number of acorns that he can bring to the nest? Note that gold, silver, or bronze brought to the nest would be worthless because he is just a squirrel.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the maximum number of acorns that Chokudai can bring to the nest.
23
1 1 1
2 1 1
46
He can bring acorns to the nest, as follows:
- In Exchange , trade acorns for grams of gold. {acorns, gold, silver, bronze}={ }
- In Exchange , trade grams of gold for acorns. {acorns, gold, silver, bronze}={ }
- In Exchange , trade nothing. {acorns, gold, silver, bronze}={ }
He cannot have or more acorns, so the answer is .