시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
4 초 (추가 시간 없음) | 512 MB | 110 | 37 | 22 | 28.205% |
Chiaki has $n$ integers $a_1, a_2, \dots, a_n$ and another integer $c$, and she would like to choose a subset of the $n$ integers whose sum does not exceed $c$. Find the maximum possible sum of the chosen subset.
There are multiple test cases. The first line of the input contains an integer $T$ ($1 \le T \le 2 \times 10^4$), indicating the number of test cases. For each test case:
The first line contains two integers $n$ and $c$ ($1 \le n \leq 2 \times 10^4$, $1 \leq c \leq 10^9$). The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \leq a_i \leq 2 \times 10^4$).
The sum of all $n$ does not exceed $2 \times 10^4$.
For each test case, output an integer denoting the answer.
3 3 5 2 3 4 3 1 2 3 4 3 1000000000 2 3 4
5 0 9