首页 / 软件开发 / 数据结构与算法 / 算法题:UVA 10154 Weights and Measures(dp)
算法题:UVA 10154 Weights and Measures(dp)2014-04-19Problem F: Weights and MeasuresI know, up on top you are seeing great sights,But down at the bottom, we, too, should have rights.We turtles can"t stand it. Our shells will all crack!Besides, we need food. We are starving!" groaned Mack.The ProblemMack, in an effort to avoid being cracked, has enlisted your advice as to the order in which turtles should be dispatched to form Yertle"s throne. Each of the five thousand, six hundred and seven turtles ordered by Yertle has a different weight and strength. Your task is to build the largest stack of turtles possible.Standard input consists of several lines, each containing a pair of integers separated by one or more space characters, specifying the weight and strength of a turtle. The weight of the turtle is in grams. The strength, also in grams, is the turtle"s overall carrying capacity, including its own weight. That is, a turtle weighing 300g with a strength of 1000g could carry 700g of turtles on its back. There are at most 5,607 turtles.Your output is a single integer indicating the maximum number of turtles that can be stacked without exceeding the strength of any one.Sample Input300 10001000 1200200 600100 101Sample Output3