Dollars
Time limit1sMemory limit128 MB
Simulate converting between dollars and marks daily using given rates to maximize final dollar amount, truncated to two decimals.
- Level
Easy3 of 10
- Topics
- Greedy, Simulation, Dynamic programming
- Solved
- No attempts yet
Problem
Dave has obtained the future exchange rates between the US dollar and the German mark for the next several days. Each day he may convert all of his money from one currency to the other at that day's rate, or leave it unchanged.
Dave starts with 100 dollars. Write a program that determines the largest amount of dollars he can hold at the end of the last day.
On a day whose rate is A, the two currencies trade as follows: 100 dollars buy A marks, and A marks buy 100 dollars. In other words, 1 dollar is worth A / 100 marks and 1 mark is worth 100 / A dollars, so converting back and forth on the same day never changes the amount. Any amount may be converted (the amounts need not be whole numbers), and money left in marks at the end of the last day does not count toward the answer.
Input
The first line contains a natural number N (1 ≤ N ≤ 100), the number of future days for which Dave knows the exchange rates.
Each of the next N lines contains a natural number A (1 ≤ A ≤ 100). The value A on the i-th of these lines is the exchange rate on the i-th day: on that day 100 dollars can be exchanged for A marks, or A marks for 100 dollars.
Output
Print a single line with the maximum amount of dollars Dave can hold at the end of the last day, truncated (rounded down) to exactly two decimal places.