For the following problem from leetcode, would it be possible to structure my recurrence relation like this for using a DP approach:
OPT[i][w] = min{cost[I][0] + OPT[I+1][w-1], costI + OPT[I+1][w]}
where OPT[I][w] represents the minimum cost of assigning the ith person to either city A or city B when city A has w more people that can move in before it reaches its capacity (essentially the current remaining capacity of city A). Choice 1 represents assigning the ith person to city A, and choice 2 represents assigning the ith person to city B.
So the min cost for this problem would be OPT[0][n], where we find the minimum cost of assigning the 0th indexed person on the costs list to city A with current remaining capacity of n people. I realize that I'm not tracking the remaining capacity of city B, but I'm assuming that as long city A reaches n people then city B will reach n people at the end too?
I've attached a screenshot of the problem and my logic for constructing the recurrence relation below. link to problem: https://leetcode.com/problems/two-city-scheduling/description/ Recurrence Relation Logic