invest
Ion has 100 RON and he wants to invest them for n months. At the beginning of each month he can select one of the following 3 options:
1. He can make a one month bank deposit. In this case his money is tied up for
a month, he will have to pay initially (at the beginning of the month) a deposit
management tax, and at the end of the month he receives a specific amount for
each invested RON. More specifically, let's say Ion has x
RON and wants to make a bank deposit at the beginning of month t.
Initially he will have to pay a tax TB(t)
and one month later he will receive SB(t)
for each RON invested, therefore the amount he will have after a month (so at
t+1) is: (x-TB(t))*SB(t).
2. He will buy a treasury bill. In this case his money is tied up for 6 months, he will have to pay a tax at the beginning of the month when he buys the treasury bill, and at the end of the 6 months he will receive a specific amount for each invested RON. More specifically, let's say Ion has x RON and wants to buy a treasury bill at the beginning of month t. Initially he will have to pay a tax TT(t) and 6 months later he will receive ST(t) for each RON invested, therefore the amount he will have at time t+6 is: (x-TT(t))*ST(t).
3. Hide the money under the mattress (save it for later). Therefore, if at moment t he has x RON then one month later (at t+1) he will still have x RON.
Task
Knowing the management taxes and the accrued amounts/RON for each of the n months, determine the maximum amount Ion can accumulate by investing the 100 RON.
Input Data
Line one of input file invest.in contains positive integer n representing the number of months. Line two contains n positive integers each separated by a space, TB1 TB2 ... TBn, representing the deposit management taxes for the beginning of each month. Line three contains n floating point numbers separated by a space, SB1 SB2 ... SBn, representing the profit obtained for each RON invested in bank deposits at the end of each month. Line four contains n positive integers separated by a space, TT1 TT2 ... TTn, representing the value of the management tax for the treasury bill corresponding to that month. Line five contains n floating point numbers separated by a space, ST1 ST2 ... STn, representing the profit obtained for each RON invested in treasury bills in month 1, 2, ..., respectively n.
Output Data
Output file invest.out will contain a single line with a single floating point number representing the maximum amount Ion can accumulate by investing the 100 RON. The result will be displayed with 4 decimals.
Constraints and Mentions
invest.in | invest.out | Explanation |
8 |
340.7500 |
Initially Ion has 100 RON. |
Time limit: 0.1 seconds/test
prof. Marinel Serban
"Grigore Moisil" Iaşi IT High School
Contact:marinel_serban@yahoo.com