P8392 [BalticOI 2022] Uplifting Excursion (Day1)
Description
There are $2m+1$ types of items, with weights $-m,-m+1,\ldots, m-1,m$. There are $a_i$ items of weight $i$.
You need to take some items such that the sum of their weights is exactly $l$. Under this condition, you need to take as many items as possible.
Ask: with the total weight exactly $l$, what is the maximum number of items you can take.
Input Format
The first line contains two numbers $m,l$.
The second line contains $2m+1$ numbers: $a_{-m},a_{-m+1},\ldots, a_{m-1},a_m$.
Output Format
Output one number in a single line, representing the answer. If no solution exists, output `impossible`.
Explanation/Hint
Subtask $1$ ($5$ points): $m , a_i≤50$.
Subtask $2$ ($15$ points): $m , a_i≤100$.
Subtask $3$ ($20$ points): $m≤30$.
Subtask $4$ ($20$ points): $m ≤50$.
Subtask $5$ ($20$ points): $m ≤ 100$.
Subtask $6$ ($20$ points): no special constraints.
For subtasks $3$ to $6$, if you pass the test points with $\forall i