This page is still under construction.

Parts of this page are still being built. What you see may change.

How to Fail at Programming Contest

Time limit1sMemory limit512 MB

Summary
Gennady picks the order of problems he solves, never starting one he cannot finish, to minimize total points scored within T minutes.
Level

Medium6 of 10

Topics
Dynamic programming, Sorting, Greedy
Solved
No attempts yet

Problem

Gennady is the best at competitive programming. He can solve any problem, so he has never lost a contest. But today he has decided to lose a contest, because winning every contest is not interesting.

Gennady cannot simply abandon solving problems, since that is unsportsmanlike behavior. So he has decided to pick a bad strategy that minimizes his total points for the contest.

There are nn problems in the contest, numbered from 11 to nn. If a contestant solves problem ii, he gets p_ip\_i points. Gennady has read all the problems and came up with a solution for each one. He knows that for problem ii he needs exactly t_it\_i minutes to write the solution. The final thing to do is to choose the order in which he writes the solutions. Gennady noticed that he has TT minutes remaining until the end of the contest.

Gennady wants to use the following strategy. He chooses a problem he has not solved yet and writes a solution for it. He never chooses a problem he cannot finish in time. When the solution is ready, Gennady submits it and gets p_ip\_i points for this problem. Submitting and testing take no time. Then he moves on to another problem. When Gennady realizes he cannot solve any of the remaining problems in time, he stops coding.

Now Gennady wants to choose the order of solving problems that minimizes his score for the contest. Help him find the smallest number of points he can get while following the rules above.

Input

The first line of input contains two integers nn and TT, the number of problems and the time until the end of the contest (1≤n,T≤20001 \leq n, T \leq 2000).

The following nn lines describe the problems. The ii-th line contains two integers t_it\_i, p_ip\_i, the time Gennady needs to solve this problem and the number of points this problem is worth (1≤t_i≤20001 \leq t\_i \leq 2000, 1≤p_i≤1061 \leq p\_i \leq 10^6).

Output

Output one number: the minimal number of points Gennady can get.

Examples2

  1. Example 1

    Input
    4 9
    4 2
    4 5
    3 4
    2 10
    
    Expected output
    7
    
  2. Example 2

    Input
    1 1
    2 1
    
    Expected output
    0