eolymp
bolt
Try our new interface for solving problems
Məsələlər

Ограбление

Ограбление

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}).
Zaman məhdudiyyəti 8 saniyə
Yaddaşı istafadə məhdudiyyəti 64 MiB
Giriş verilənləri #1
2
2 4
3 2
5 3
3 100
4 7 1
5 9 2
Çıxış verilənləri #1
6
29
Mənbə Southeastern European Regional Programming Contest, Bucharest, Romania, October 17, 2009