문제
As a delivery driver for a food delivery service, you can work in one of three different cities each day: Denver, Ft. Collins, or Colorado Springs.
While working for the past few years, you have collected data on your net profit from working in each city and applied a predictive machine learning model that allows you to know exactly how much net profit you can make from working in each city for the next days.
The model shows that you can make different amounts of money on each day, depending on the location. Naturally, you want to work in the city where you can make the most money each day. However, driving from one city to the next is not without cost, so in some cases it may be better to stay where you are and make slightly less but not have to drive to a different city.
The cost to drive between cities ( and ) is given by , a constant representing how costly it is to drive from to . Note that is always equivalent to .
You want to determine which city to work in on each of the next days such that your total net profit across all of the days is maximized. (Net profit is calculated by taking the total earnings and subtracting both the operating costs for each day as well as any transition costs incurred by driving between cities.)
Consider the following example (which describes the first sample input). You are planning for the next days and have calculated the profit you could make in each of the cities as shown in the table below:
| City | Day 1 | Day 2 | Day 3 |
|---|---|---|---|
| Denver | 251\ | 398\ | 92\ |
| Colorado Springs | 148\ | 402$ |
Further, assuming that \begin{align*} T(\text{Denver}, \text{Ft. Collins}) &= \$20, \\ T(\text{Denver}, \text{Colorado Springs}) &= \34, \end{align*} if you choose to work from Denver on day , Colorado Springs on day and day , then your total net profit would be: \begin{align*} P_\text{total} &= \underbrace{\117}_\text{Denver to Colorado Springs} + \underbrace{\2402}_\text{Day profit} = \123$, then your total net profit would be: \begin{align*} P_\text{total} &= \underbrace{\$251}_\text{Day profit} - \underbrace{\151}_\text{Day profit} - \underbrace{\410}_\text{Day profit} = \3NP$ across all of the days is maximized? Note that you can start and end in any city you wish, and the start and end cities do not have to be the same.