P2920 [USACO08NOV] Time Management S

Description

Ever the maturing businessman, Farmer John realizes that he must manage his time effectively. He has N jobs conveniently numbered 1..N (1

Input Format

\* Line 1: A single integer: N \* Lines 2..N+1: Line i+1 contains two space-separated integers: T\_i and S\_i

Output Format

Farmer John has 4 jobs to do, which take 3, 8, 5, and 1 units of time, respectively, and must be completed by time 5, 14, 20, and 16, respectively. Farmer John must start the first job at time 2. Then he can do the second, fourth, and third jobs in that order to finish on time.

Explanation/Hint

**【样例解释】** 约翰有 $4$ 个工作要做,分别需要 $3、8、5$ 和 $1$ 个时间单位,并且必须分别在时间 $5、14、20$ 和 $16$ 之前完成。 约翰必须在时间 $2$ 开始第一个作业。然后他可以按此顺序完成第二、第四和第三项工作,以按时完成。