Fundraised
InterviewTime limit1sMemory limit128 MB
Choose unlimited units of N item kinds within budget X to maximize total importance.
- Level
Easy3 of 10
- Topics
- Dynamic programming
- Solved
- No attempts yet
Problem
Dalia won a prize of X, and now the money has to be spent. Mohamed Fouad, the deputy regional contest director, wants to spend it but cannot decide what to buy. There are N kinds of items he can buy: name tags, T-shirts, helium balloons, trophies, and so on. Each kind has its own importance value and its own price per unit. He can buy as many units of any kind as he wants, as long as the total price stays within the budget.
Find the largest total importance value Fouad can reach by choosing what to buy without going over the budget.
Input
The first line contains an integer T, the number of test cases.
The first line of each test case contains two integers N () and X (), the number of item kinds and the budget. The second line contains N integers () separated by spaces, where is the importance value Fouad earns from one unit of item i (). The third line contains N integers () in the same format, where is the price of one unit of item i.
Output
For each test case, print the maximum total importance value Fouad can get on its own line.