Given a wooden board consisting of MXN wooden square pieces, we need to find the minimum cost of breaking the board into square wooden pieces.
We can cut the board in horizontal and vertical lines, and each cut divides the board into smaller parts. Each section of the board has a cost depending on whether the section is made along a horizontal or vertical line.
Denote the cost of cutting along successive vertical lines with x [1], x [2], ..., x [n-1] and along horizontal lines with y [1], y [2], ..., y [m-1]. If the cut (cost c) is made and passes through n segments, then the total cost of this cut will be n * c.
The cost of cutting the entire board into individual squares is the sum of the cost of successive cuts used to cut the entire board into 1x1 square wooden pieces.
What is the minimum cost of breaking an entire wooden board into 1x1 squares.
Example: take a 6 * 4 grid.
Let me cut the line costs as follows: [2 1 3 1 4]
The column cost reduction as follows: [4 1 2]
Here the answer will be 42
, y5, x1, y3, y1, x3, y2, y4 x2, . , cost = y5 = 4. x1. ( ), 2 * x1 = 2 * 4. (y3) 2 * y3 = 2 * 3. 4 + 4 * 2 + 3 * 2 + 2 * 2 + 2 * 4 + 1 * 3 + 1 * 3 + 1 * 6 = 42.
: , 1 2- , . , , . ?