#P8392. [BalticOI 2022] Uplifting Excursion (Day1)

    ID: 9495 远端评测题 1000~4000ms 128MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>动态规划 DP贪心2022BalticOI(波罗的海)

[BalticOI 2022] Uplifting Excursion (Day1)

Problem Description

There are 2m+12m+1 types of items, with weights m,m+1,,m1,m-m,-m+1,\ldots, m-1,m. There are aia_i items of weight ii.

You need to take some items such that the sum of their weights is exactly ll. Under this condition, you need to take as many items as possible.

Ask: with the total weight exactly ll, what is the maximum number of items you can take.

Input Format

The first line contains two numbers m,lm,l.

The second line contains 2m+12m+1 numbers: am,am+1,,am1,ama_{-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.

2 5
2 3 1 1 4

9

3 5
3 1 0 2 0 0 2
impossible

Hint

Subtask 11 (55 points): m,ai50m , a_i≤50.

Subtask 22 (1515 points): m,ai100m , a_i≤100.

Subtask 33 (2020 points): m30m≤30.

Subtask 44 (2020 points): m50m ≤50.

Subtask 55 (2020 points): m100m ≤ 100.

Subtask 66 (2020 points): no special constraints.

For subtasks 33 to 66, if you pass the test points with i<0,ai=0\forall i<0,a_i=0, you can get half of the score.

For all data, 1m3001\leq m \leq 300, 1018l1018-10^{18}\le l \le 10^{18}, 0ai10120\le a_i\le 10^{12}.

Translated by ChatGPT 5