Dynamic Programming and Knapsack Application

前端 未结 4 1678
遇见更好的自我
遇见更好的自我 2020-12-29 00:26

Im studying dynamic programming and am looking to solve the following problem, which can be found here http://www.cs.berkeley.edu/~vazirani/algorithms/chap6.pdf:

You

4条回答
  •  南方客
    南方客 (楼主)
    2020-12-29 01:01

    I think you should focus on the fact that the machine cuts the cloth into two pieces. What can fit in each of those two pieces? Consider the following:

    +-------------+-------------------+
    |             |       Piece B     |
    |             |                   |
    |  Piece A    +----------+--------+
    |             |          |        |
    |             |          |        |
    |             |          | Piece  |
    +-------------+----------+   C    |
    |                        |        |
    |         Piece D        |        |
    +------------------------+--------+
    

    These four fit in the cloth, but not in a way that's possible to achieve with three cuts. (Possibly a different arrangement would allow that with these particular pieces; think of this as a conceptual diagram, not to scale. My ascii art skills are limited today.)

    Focussing on "where is the cut" should give you the dynamic programming solution. Good luck.

提交回复
热议问题