Logo
(追記) (追記ここまで)

23492번 - Subset Sum 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 (추가 시간 없음) 512 MB219773023.256%

문제

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.

제한

예제 입력 1

3
3 5
2 3 4
3 1
2 3 4
3 1000000000
2 3 4

예제 출력 1

5
0
9

힌트

출처

Contest > Open Cup > 2019/2020 Season > Stage 18: Grand Prix of Bytedance F번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /