+ 3

Can anyone help me to solve this, as I'm finding difficult to solve it.

Raju sells Diwali sweets with three different combinations, D1, D2 and D3. There are total X,Y, and Z sweets with combinations, D1,D2, and D3 respectively. Each sweets combination has an integer value called deliciousness as follows: The deliciousness of the sweets with the D1 combination are D11,D12,D13,....,D1X. The deliciousness of the sweets with the D2 combination are D21,D22,D23,....,D2Y. The deliciousness of the sweets with the D3 combination are D31,D32,D33,....,D3Z. Sanju decides to buy K boxes containing three sweets, one from each of the combinations. The deliciousness of a box is the sum of the deliciousness of the sweets present inside it. There are X∗Y∗Z such ways to select a box. Print the maximum total sum of deliciousness that Sanju can get by buying K boxes from Raju. I have mentioned input and output specifications bellow

4th Nov 2022, 1:08 PM
GURURAJ KL
GURURAJ KL - avatar
2 Respuestas
+ 3
Input -> The first line contains an integer T denoting the number of test cases. The first line of each test case contains three space-separated integers X, Y, and Z. The second line of each test case contains a single integer K. The third line of each test case contains X space-separated integers denoting array D1i. The fourth line of each test case contains Y space-separated integers denoting array D2j. The fifth line of each test case contains Z space-separated integers denoting array D3k.
4th Nov 2022, 1:10 PM
GURURAJ KL
GURURAJ KL - avatar
+ 3
Output -> For each test case, print the maximum total sum of deliciousness that Sanju can get by buying K boxes in a new line. Constraints 1 ≤ T ≤ 10 1 ≤ X,Y,Z ≤ 1000 1 ≤ K ≤ min(3000,X∗Y∗Z)1 ≤ D1i,D2j,D3k ≤ 1000000000 Example Input: 2 2 2 2 7 4 6 1 5 3 8 6 3 2 32 6 9 8 8 1 8 5 7 3 9 3 Returns: 100 597 Explanation: For the first testcase, the combinations of burger in the boxes are (D11,D21,D32),(D11,D22,D31),(D11,D22,D32),(D12,D21,D31),(D12,D21,D32),(D12,D22,D31) and (D12,D22,D32). Thus, the total sum of deliciousness Rocky can buy is 100.
4th Nov 2022, 1:10 PM
GURURAJ KL
GURURAJ KL - avatar