Authors: Antropov A., Sheshukova M.

Marina bought a tour to Banana Country from October 5 to October 22. Importing and exporting bananas across the border is prohibited. The Banana King issues a decree on prices at the beginning of each month. The price of one banana in the local currency for the relevant dates in October is given in the table:

| $\$ 1, \$ 5$ | $\$ 1, \$ 6$ | $\$ 1, \$ 7$ | $\$ 1, \$ 8$ | $\$ 1, \$ 9$ | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- |
| 8,1 | $\$ 1, \$ 8$ | $\$ 1, \$ 7$ | 8,1 | $\$ 1, \$ 9$ | $\$ 1, \$ 8$ | 8,1 | 7,2 | $\$ 1, \$ 7$ | $\$ 1, \$ 8$ | $\$ 1, \$ 9$ | 8,1 | $\$, \$ 9$ | $\$ 1, \$ 8$ | $\$, \$ 9$ | 8,2 | $\$ 1, \$ 7$ | 7,1 |

Marina wants to eat one banana per day. She only likes green bananas, so she is willing to eat a banana only within 4 days after purchase. For example, a banana bought on October 5, Marina is willing to eat on October 5, 6, 7, or 8. Marina can stock up on bananas when they are cheaper.

On which days and how many bananas should Marina buy to spend as little money as possible?
To solve the problem, it's enough to look at it correctly. Instead of thinking about how many bananas to buy each day, let's choose for each day which of the days to buy bananas from! For this, we need to choose the lowest price from four: the current day and the three previous ones (if there are fewer than three previous days, we only look at the ones that are available).

For each day on the chart below, an arrow indicates the lowest price among the available ones. Accordingly, on each day, you should buy as many bananas as the number of arrows pointing to the price under that day.

![](https://cdn.mathpix.com/cropped/2024_05_06_180c6050e42e6bfd9e50g-10.jpg?height=283&width=2035&top_left_y=1665&top_left_x=0)

We get the answer:

![](https://cdn.mathpix.com/cropped/2024_05_06_180c6050e42e6bfd9e50g-10.jpg?height=148&width=2060&top_left_y=2004&top_left_x=-1)

## Answer

From October 5 to October 22, you need to buy, respectively, $1,1,4,0,0,1,0,1,4,1,0,0,0,3,0,0,2,0$ bananas. Leave a comment

Problem