Implement the function max_total_sweetness which calculates the maximum total sweetness achievable by buying at most two types of candies within a given monetary limit.
Functionality Requirements
The function should accept two parameters:
An integer T, denoting the number of test cases.
A list test_cases of length T, where each test case is a tuple containing:
An integer N, the number of candy types.
An integer D, the monetary limit for purchasing candies.
A list of integers prices, where each element represents the price of a candy type.
A list of integers sweetness, where each element represents the sweetness value of the corresponding candy type.
The function should return a list of integers, where each integer represents the maximum total sweetness obtainable for the corresponding test case while staying within the monetary limit.
Input/Output Requirements
Input:
T (1 <= T <= 100)
test_cases (length of test_cases = T, each test case follows the structure mentioned above)
N (1 <= N <= 50)
D (0 <= D <= 10^9)
prices (length N, the values are between 1 and 10^9)
sweetness (length N, the values are between 1 and 10^9)
Output:
Return a list of integers, where the ith element is the maximum total sweetness for the ith test case.
Example
python
# Input
result = max_total_sweetness(2, [(3, 10, [2, 5, 8], [1, 2, 3]), (3, 3, [1, 2, 3], [4, 5, 6])])
# Output
print(result) # Output should be [3, 6]
File Structure
The solution must be implemented in a file named /app/solution.py.