3219. Minimum Cost for Cutting Cake II
There is an
m x ncake that needs to be cut into1 x 1pieces.You are given integers
m,n, and two arrays:
horizontalCutof sizem - 1, wherehorizontalCut[i]represents the cost to cut along the horizontal linei.verticalCutof sizen - 1, whereverticalCut[j]represents the cost to cut along the vertical linej.In one operation, you can choose any piece of cake that is not yet a
1 x 1square and perform one of the following cuts:
- Cut along a horizontal line
iat a cost ofhorizontalCut[i].- Cut along a vertical line
jat a cost ofverticalCut[j].After the cut, the piece of cake is divided into two distinct pieces.
The cost of a cut depends only on the initial cost of the line and does not change.
Return the minimum total cost to cut the entire cake into
1 x 1pieces.
1 |
|