Problem F:weights and Measures
I know, up to top you are seeing great sights,
But down at the bottom, we, too, should have rights.
We turtles can ' t stand it. Our shells'll all crack!
Besides, we need food. We are starving! "groaned Mack.
The Problem
Mack, in a effort to avoid being cracked, has enlisted your advice ' as to the ' order in which turtles ' should 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 to one or more spaces characters, SP Ecifying the weight and strength of a turtle. The weight of the turtle is in grams. The strength, also in grams, are the turtle ' s overall carrying, capacity its including own. This is, a turtle weighing 300g with a strength of 1000g could carry 700g of turtles in its back. There are at most 5,607 turtles.
Your output is a single integer indicating the maximum number of turtles so can be stacked without the exceeding H of any one.
Sample Input
300 1000
1000 1200
200 600
100 101
Sample Output
3