Collect Points

5

1 votes
Dynamic Programming, Easy
Problem

There are N distinct items available for sale in various shops. 

For each item x where 1<=x<=N, you know:
1) total[x] - the total number of shops that sells this item.
2) points[x] - the points you achieve by purchasing this item from any one of the shops.
3) cost[x] - the cost (in $ (dollars)) you need to pay to purchase this item from all the shops.

Now, you have a total of only $M (dollars). Find the maximum points you can gain by optimally purchasing the items such that total cost doesn't exceed $M (dollars).


Input format:

First line consists of T , denoting number of test cases.
For each testcase:
 First line consists of N and M.
 Second line consists of N numbers seperated by a space, denoting total[x]. where 1<=x<=N.
 Third line consists of N numbers seperated by a space, denoting points[x]. where 1<=x<=N.
 Fourth line consists of N numbers seperated by a space, denoting cost[x]. where 1<=x<=N.


Output format:

For each query, output the required answer on a new line.


Constraints:

1 <= T <= 100
1 <= N <= 100
1 <= M <= 100
1 <= total[i],points[i],cost[i] <= 100

Where 1<=i<=N

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

Purchase 1st and 3rd item. Total cost = 3 + 3 = 6.
Total points = (1 * 2) + (3 * 3) = 11.

Editor Image

?