Coding Spree

View as PDF

Submit solution

Points: 10 (partial)
Time limit: 0.6s
Memory limit: 16M

Author:
Problem type

It's almost report card time, so of course everyone has started programming like mad. There are only T (1 \le T \le 1\,000) hours left before the Sunday midnight deadline!

Luckily, you've earned your points gradually, so now you can just sit back and watch your classmates struggle. One of your friends in particular is really screwed, so he's decided to skip school all week and go on a coding spree.

Though your friend is lazy, he has done some problems on the Judge, so now he has exactly N (1 \le N \le 1\,000) problems available to him. No more problems will be posted until after the deadline, and he can't get partial marks on any of these problems. Problem i is worth V_{i} points and he knows in advance that he can solve it in H_{i} hours (1
\le V_{i}, H_{i} \le 1\,000).

You're not a very pleasant person, so you want to torture your friend a bit. You plan to calculate the most points your friend could possibly get by the deadline, just so you can taunt him with that number.

Input Specification

Line 1: The integers N and T.
The next N lines: Line i+1 contains the integers V_{i} and H_{i}.

Output Specification

Output the maximum amount of points your friend can get in at most T hours of coding.

Sample Input

8 48
10 7
5 1
50 30
5 1
10 5
100 1000
25 10
60 40

Sample Output

95

Explanation

Your friend only has 48 hours, and 8 problems to choose from. To maximize his points, he should do problems 2, 3, 4, 5, and 7, giving him 95 points in 47 hours.


Comments

There are no comments at the moment.