Sabke Paas Hanuman nahi hote Laxman

5

2 votes
Problem

Meghnath used his shakti arrow on Laxman Ji. Since Laxman Ji is inexperienced, he got hit by a shakti arrow and fainted. He needs a dose of Sanjeevani Booti so that he can stand on his own feet again. Hanuman Ji was asked to fetch Sanjeevni Booti from Dronagiri.

He sees that there are \(N\) blocks of Sanjeevani Booti there. Each block has its own power \(p_i\) and effectiveness \(e_i \). Hanuman Ji does not know how much Sanjeevani Booti can cure Laxman Ji So he wants to maximize the effectiveness of Sanjeevani Booti.

But Hanuman Ji can withstand with a maximum total power of all blocks \(P \). So you have to tell the maximum effectiveness of Sanjeevani Booti he carries back to Laxman.

Input Format

First-line contains two Integers \(N\) and \(P\).

Next \(N\) lines, each line contains two integers \(p_i\) and \(e_i\) , power of \(i_{th}\) block and effectiveness of \(i_{th}\) block.

Output Format

Single line contains one integer, maximum effectiveness Hanuman Ji carries back.

Constraints

\(1 \leq N \leq 200\)

\(1 \leq P \leq 2 \times 10^7\)

\(1 \leq p_i \leq P\)

\(1 \leq e_i \leq 2000\)

Sample Input
6 15
6 5
5 6
6 4
6 6
3 5
7 2
Sample Output
17
Time Limit: 10
Memory Limit: 1536
Source Limit:
Editor Image

?