Algorithm title: UVA 10154 Weights and Measures (DP)

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.