## Welcome To SDIBT ACM-ICPC Online Judge

VIRTUAL JUDGE Recent Contest F.A.Qs Discuss Home ProblemSet Status Ranklist 14 Contest LoginRegister Exam
2017 ACM 集训队预选排名~      报名入口
Problem 1096. -- Weights and Measures

## Weights and Measures

Time Limit: 1 Sec  Memory Limit: 256 MB
Submit: 19  Solved: 9
[Submit][Status][Discuss]

## Description

A turtle named Mack, to avoid being cracked, has enlisted your advice as to the order in which turtles should be stacked to form Yertle the Turtle's throne. Each of the 5,607 turtles ordered by Yertle has a different weight and strength. Your task is to build the largest stack of turtles possible.

## Input

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 300 g with a strength of 1,000 g can carry 700 g of turtles on its back. There are at most 5,607 turtles.

## Output

Your output is a single integer indicating the maximum number of turtles that can be stacked without exceeding the strength of any one.

## Sample Input

```300 1000
1000 1200
200 600
100 101
```

```3
```

## Source

UVA toolkit

[Submit][Status][Discuss]

HOME Back

한국어 中文 English
All Copyright Reserved 2008-2010 SDIBT TEAM
GPL2.0 2003-2010 HUSTOJ Project TEAM