Can you please explain me the meaning of this question. I don’t need the code, just the explanation.
PROBLEM STATEMENT:
There are two towns A and B respectively. Both the towns are organizing an international trade festival. Initially, you have n bitcoins. Now, as you are fond of trading, firstly you decide to go to town A and participate in some finite number of the trade process. Then you decide to go to town B and participate in some finite number of trade processes in town B and finally, you return again to town A and participate in some finite number of the trade processes.
A trade process in town x={A, B} can be one among the following (any number of times in any order) -
Pay gx bitcoins and get 1 unit gold.
Pay 1 unit gold and get gx bitcoins.
Pay sx bitcoins and get 1 unit silver.
Pay 1 unit silver and get sx bitcoins.
Pay bx bitcoins and get 1 unit bronze.
Pay 1 unit bronze and get bx bitcoins.
Note: You can only participate in a trade process if neither the number of bitcoins nor the count of units of any of the coins goes less than zero.
You need to find the maximum number of bitcoins you can achieve at last. The number of units of gold, silver and bronze in the end does not matter.
Input Format
The first line of input contains n (1≤ n ≤ 5000), the number of bitcoins initially.
Next two lines contain gx, sx and bx (1 ≤ gx,sx,bx ≤ 5000).
Output Format
Print a single integer, the maximum number of bitcoins at the end.