We have some boxes numbered 1 to N . The dimensions of all boxes are identical. Now we have to stack up some of the boxes, subject to the following constraints:
Please write a program that finds the maximum number of boxes that can be stacked up according to the above constraints.
The first line of each set of input is an integer N (1 ≤ N ≤ 1000). This is followed by N lines, each with two integers, both ≤ 3000, representing the weight and maximum load of each box respectively. Input ends with a case where N = 0.
Each line of your output should give the number of boxes that can be stacked up.
範例輸入 1
5 19 15 7 13 5 7 6 8 1 2 0
範例輸出 1
4
Pro 專屬功能: 查看這題在歷屆 CPE 出現過幾次 — 升級以解鎖.