题目描述
Problem Description
In the year 20XX, Penguin-kun has become a high school teacher and is diligently working on creating the final exams.
There are $ N $ problems, and Penguin-kun needs to select at least one of them to create the final exam. The exam duration is fixed at $ T $ minutes, but the number of problems chosen is free.
The final exam will be solved by Penguin-kun's students, among whom are Taro-kun and Jiro-kun. For each $i\ (1\ \leq\ i\ \leq\ N)$, it is known that Taro-kun takes $ A_i $ minutes to solve the $ i $th problem, and Jiro-kun takes $ B_i $ minutes.
Penguin-kun wants to create an exam that is as advantageous as possible for Taro-kun. By carefully selecting the problems, maximize the difference between the number of problems solved by Taro-kun and the number of problems solved by Jiro-kun.
Both Taro-kun and Jiro-kun will solve as many problems as possible during the exam.
Input Format
The input is given from the standard input in the following format:
$ N $ $ T $ $ A_1 $ $ B_1 $ $ A_2 $ $ B_2 $ $\hspace{0.6cm}\vdots$ $ A_N $ $ B_N $
Output Format
Output the maximum value of (the number of problems solved by Taro-kun) - (the number of problems solved by Jiro-kun).
Sample Input and Output
Sample Input #1
4 8
3 4
5 3
3 4
4 5
Sample Output #1
1
Sample Input #2
6 10
1 2
2 3
2 5
4 7
4 8
5 10
Sample Output #2
2
Sample Input #3
10 100
95 5
85 70
8 44
71 66
74 11
39 2
26 81
29 23
92 70
52 57
Sample Output #3
2
Notes/Hints
Constraints
- $1\ \leq\ N\ \leq\ 1000$
- $1\ \leq\ T\ \leq\ 10000$
- $1\ \leq\ A_i,B_i\ \leq\ T$
- All inputs are integers
Subtasks
- ($ 50 $ points) $N\ \leq\ 16$
- ($ 150 $ points) For all $ (i,j) $, if $A_i\ \lt\ A_j$ then $B_i\ \leq\ B_j$, $T\ \leq\ 100$
- ($ 150 $ points) For all $ (i,j) $, if $A_i\ \lt\ A_j$ then $B_i\ \leq\ B_j$
- ($ 250 $ points) No additional constraints
Sample Explanation 1
When the 1st and 4th problems are chosen for the exam, Taro-kun solves 2 problems and Jiro-kun solves 1 problem. There is no way to select problems that would result in a higher value of (the number of problems solved by Taro-kun) - (the number of problems solved by Jiro-kun), so the answer is $ 1 $. This input satisfies the constraints of Subtasks $ 1,4 $.
Sample Explanation 2
This input satisfies the constraints of all subtasks.
Sample Explanation 3
This input satisfies the constraints of Subtasks $ 1,4 $. Original idea: penguinman
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分