#P6437. [COCI 2011/2012 #6] JACK
[COCI 2011/2012 #6] JACK
Problem Description
Given positive integers , choose numbers such that their sum is not greater than the given integer . Find the maximum possible value of this sum.
Input Format
The first line contains two integers, representing the number of integers and the given integer .
The second line contains integers, representing the given numbers .
Output Format
Output one integer in one line, representing the answer.
5 21
5 6 7 8 9
21
10 500
93 181 245 214 315 36 185 138 216 295
497
Hint
Constraints
- For of the testdata, it is guaranteed that , , , and it is guaranteed that a solution exists.
Notes
This problem is translated from COCI2011-2012 CONTEST #6 T1 JACK. Translation by @一扶苏一.
Translated by ChatGPT 5