You're in a book shop with books. Each book has a price and a number of pages. You have a budget of . Buy books to get the highest total pages.
Sound familiar? This is 0/1 Knapsack wearing a disguise. , , . Before reading on, try to map this problem to the knapsack framework you already know. Read the problem statement carefully, noting the constraints. Try to identify the recursive structure before looking at the solution.