## Coding Spree

It's almost report card time, so of course everyone has started programming like mad. There are only T (1 ≤ T ≤ 1000) 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 ≤ N ≤ 1000) 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 Vi points and he knows in advance that he can solve it in Hi hours (1 ≤ Vi, Hi ≤ 1000).

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

 Line 1: The integers N and T The next N lines: Line i+1 contains the integers Vi and Hi

### Output

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

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

`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.

Point Value: 10 (partial)
Time Limit: 1.00s
Memory Limit: 16M
Added: Jan 05, 2009
Author: SourSpinach

Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3

## Comments (Search)

• (0/0)

• (0/0)
seems to be working fine with me

• (0/0)
I got AC on this problem with a solution a few months ago that terminates if there is insufficient input, and I just confirmed that nothing looks fishy about the input data.

• (0/0)
I guess the problem is related to cin as it disappeared when I switched to scan().

• (0/0)
so it's impossible to beat Hanson on this one I guess.

• (0/0)
LOL C FTW

• (0/0)
or i mean, resubmit FTW xD

• (3/0)
You're going to get banned if you keep doing this.

• (0/0)
...

• (1/0)
This is a basic example of a "Knapsack Problem".
Think of breaking this down into the subproblem "what's the maximum number of points I can get in X hours, using some set of the first Y problems".