You are in a panic! While writing the CCC and with time ticking down, you have minutes left during the CCC. However, you know that you cannot finish each of the subtasks remaining with the given time. Each subtask is worth points and takes minutes . Thus, in order to optimize your performance, you want to find the maximum number of points that you can get.
Input Specification
The first line of input will contain two space-separated integers and , representing the number of problems and time remaining respectively.
The next lines of input will contain two space-separated integers and , representing the number of points the subtask is worth and the time the subtask takes to complete.
Output Specification
Output one integer, representing the maximum number of points that can be obtained in the given minutes.
Subtasks
Subtask 1 [20%]
Subtask 2 [50%]
Subtask 3 [30%]
Sample Input 1
4 10
3 3
5 4
7 5
15 7
Sample Output 1
18
Sample Explanation 1
The maximum number of points attainable is through using 3 minutes to finish the first subtask, followed by using 7 minutes to finish the fourth subtask.
Sample Input 2
4 10
3 5
8 5
4 6
10 8
Sample Output 2
11
Sample Explanation 2
The maximum number of points attainable is through using 10 minutes to finish the first two subtasks.
Comments