Subset Sum
면접 대비시간 제한4초메모리 제한512 MB
n개의 정수와 상한 c가 주어질 때, 합이 c를 넘지 않으면서 최대가 되는 부분집합의 합을 구한다.
문제
Chiaki has integers and another integer , and she would like to choose a subset of the integers whose sum does not exceed . Find the maximum possible sum of the chosen subset.
입력
There are multiple test cases. The first line of the input contains an integer (), indicating the number of test cases. For each test case:
The first line contains two integers and (, ). The second line contains integers ().
The sum of all does not exceed .
출력
For each test case, output an integer denoting the answer.