Dynamic programming question

前端 未结 5 778
北海茫月
北海茫月 2021-02-02 02:55

A circus is designing a tower routine consisting of people standing atop one another’s shoulders. For practical and aesthetic reasons, each person must be both shorter and light

5条回答
  •  醉话见心
    2021-02-02 03:06

    You might need to say something about the weights & heights all being unique. Otherwise, if

    A is (10, 10) // (w, h)
    B is ( 9, 10)
    C is ( 9,  8)
    

    Then neither method gets the correct answer! C obviously can stand on A's shoulders.


    Edit:

    Neither method is good enough!

    Example with all weights & heights unique:

    A : (12, 12)
    B : (11,  8)
    C : (10,  9)
    D : ( 9, 10)
    E : ( 8, 11)
    F : ( 7,  7)
    

    Both methods give an answer of 2, however the tower can be at least of height 3 with several combinations:

    • A on the bottom,
    • then any of B, C, D, or E,
    • then F on top.

    I think stricter rules on the input data are needed to make this problem solvable by the given methods.

提交回复
热议问题