P6437 [COCI 2011/2012 #6] JACK
Description
Given $n$ positive integers $a_1 \dots a_n$, choose $3$ numbers such that their sum is not greater than the given integer $m$. Find the maximum possible value of this sum.
Input Format
The first line contains two integers, representing the number of integers $n$ and the given integer $m$.
The second line contains $n$ integers, representing the given numbers $a_i$.
Output Format
Output one integer in one line, representing the answer.
Explanation/Hint
#### Constraints
- For $100\%$ of the testdata, it is guaranteed that $1 \leq n \leq 100$, $6 \leq m \leq 3 \times 10^5$, $1 \leq a_i \leq 10^5$, and it is guaranteed that a solution exists.
#### Notes
**This problem is translated from [COCI2011-2012](https://hsin.hr/coci/archive/2011_2012/) [CONTEST #6](https://hsin.hr/coci/archive/2011_2012/contest6_tasks.pdf) *T1 JACK***. Translation by @[一扶苏一](https://www.luogu.com.cn/user/65363).
Translated by ChatGPT 5