Redian新闻
>
career cup 上9.4题答案是否正确
avatar
career cup 上9.4题答案是否正确# JobHunting - 待字闺中
i*s
1
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 lighter than the person below him or her. Given the
heights and weights of each person in the circus, write a method to compute
the largest possible number of people in such a tower.
EXAMPLE:
Input (ht, wt): (65, 100) (70, 150) (56, 90) (75, 190) (60, 95) (68, 110)
Output: The longest tower is length 6 and includes from top to bottom: (56,
90) (60,95) (65,100) (68,110) (70,150) (75,190)
avatar
g*s
2
第2步就是典型的dynamic programming
a[0].....a[n]
j->0,n, 对于每个状态j,找到以a[j]结尾的largest increasing sequence.
然后状态j+1怎么得到,比较a[j+1] with a[0]...a[j], if a[j+1] > a[i] and a[i]
has the largest increasing sequence among a[0]...a[j], the largest increasing
sequence for 状态j+1 = the largest increasing
sequence for 状态 i + a[j+1]
至于career cup上的第2步做法也是对的,就是了
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。