eolymp
bolt
Спробуйте наш новий інтерфейс для відправки розв'язків
Задачі

Пограбування

Пограбування

In the downtown of Bucharest there is a very big bank with a very big vault. Inside the vault there are \textbf{N} very big boxes numbered from \textbf{1} to \textbf{N}. Inside the box with number \textbf{k} there are \textbf{k} very big diamonds, each of weight \textbf{W}_k and cost \textbf{C_k}. John and Brus are inside the vault at the moment. They would like to steal everything, but unfortunately they are able to carry diamonds with the total weight not exceeding \textbf{M}. Your task is to help John and Brus to choose diamonds with the total weight less than or equal to \textbf{M} and the maximal possible total cost. \InputFile The first line contains single integer \textbf{T} -- the number of test cases. Each test case starts with a line containing two integers \textbf{N} and \textbf{M} separated by a single space. The next line contains \textbf{N} integers \textbf{W_k} separated by single spaces. The following line contains \textbf{N} integers \textbf{C_k} separated by single spaces. \OutputFile For each test case print a single line containing the maximal possible total cost of diamonds. \textbf{Constraints} \textbf{1} <= \textbf{T} <= \textbf{74}, \textbf{1} <= \textbf{N} <= \textbf{15}, \textbf{1} <= M <= \textbf{1000000000} (\textbf{10^9}), \textbf{1} <= \textbf{W_k}, \textbf{C_k} <= \textbf{1000000000} (\textbf{10^9}).
Ліміт часу 8 секунд
Ліміт використання пам'яті 64 MiB
Вхідні дані #1
2
2 4
3 2
5 3
3 100
4 7 1
5 9 2
Вихідні дані #1
6
29
Джерело Southeastern European Regional Programming Contest, Bucharest, Romania, October 17, 2009