Stealing books - MarisaOJ: Marisa Online Judge

Stealing books

Time limit: 1000 ms
Memory limit: 256 MB
Marisa has broken into the library of Scarlet Devil Mansion. There are n books here, the ith book weighs wi and Marisa can read this book in vi days. Now she wants to "steal" some books, but their weight cannot exceed S. She also wants to read these books in as much time as possible. ### Input - The first line contains 2 integers n,S - The next n lines, each line contains 2 integers wi,vi. ### Output - Print the maximum reading time. ### Constraints - 1≤n≤40. - 1≤wi,vi,S≤109. ### Example Input: 34112233 Output: 4