A*********r 发帖数: 564 | 1 原题如下:
9.7 A circus is designing an act consisting of a tower of people
standing atop one another’s shoulders. For practical and aesthetic reasons,
each person must be both shorter and lighter than the person below her.
Given the heights and weights of each person in the circus, what is the
largest possible number of people in such a tower?
我理解的就是要先sort一下,然后再在weight里找LIS就好了,这个要用
DP需要额外保存一数组,最好的复杂度是O(nlogn).
CareerCup给出的算法貌是不对的,从每一个unfit开始重新计算LIS
,只有O(n)的样子, 还是我理解有误? | p********7 发帖数: 549 | 2 这个题在排序身高之后直接变为找到最长递增序列,你说的没错 |
|