시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 512 MB83101012.346%

문제

Those events you attended on your arrival day were an exciting opportunity to become familiar again with the state of the (contemporary) art. And even more: The rumors you heard there revealed that the art collection you are interested in is stored in a secret underwater vault in the nearby Baltic Sea, owned by an old Lübeck grain merchant family! In memory of your past as an art thief, you decided to plan to break into this vault as a relaxing afternoon activity.*

There surely is some pun about phishing hidden here, but to be honest we’re out of our depth

To break into the vault, you want to use your newly acquired submarine. Unfortunately, your submarine will need a very specific amount of uplift $L$ when you try to escape from the crime scene. After all, you don’t want your submarine to crash into the bottom of the sea or float on the water surface where the police could catch you easily!

In order to plan your break-in accordingly, you need to know about the uplift of the art pieces in the vault. Skilled as you are, you were able to obtain relevant information. For every possible uplift $\ell$ you now know how many art pieces $A_\ell$ with that uplift are stored in the vault.

Write a program that uses this information to either calculate the maximum number of art pieces you can steal such that their total uplift (obtained by summing the individual uplift of every stolen art piece) is exactly $L$ or to decide that this is impossible.


* A purely hypothetical heist, of course.

It’s not your fault that their security system uses a weak hash algorithm, is it?

입력

The first line of input contains two integers $M$ and $L$, meaning that the uplift of every art piece in the vault is between $-M$ and $M$ inclusive and that the total required uplift is $L$.

The next line contains $2M + 1$ integers $A_{-M}$, $\dots$, $A_M$ where $A_\ell$ describes the number of art pieces with uplift $\ell$ in the vault.

출력

Your program should output a single line. This line should consist of an integer, the maximum number of art pieces you can steal such that their total uplift is exactly $L$, or the string impossible if there is no way to achieve this.

제한

We always have $1 ≤ M ≤ 300$, $-10^{18} ≤ L ≤ 10^{18}$, and $0 ≤ A_\ell ≤ 10^{12}$.

서브태스크

번호배점제한
15

$M, A_\ell ≤ 50$

215

$M, A_\ell ≤ 100$

320

$M ≤ 30$

420

$M ≤ 50$

520

$M ≤ 100$

620

No further constraints.

예제 입력 1

2 5
2 3 1 1 4

예제 출력 1

9

예제 입력 2

3 5
3 1 0 2 0 0 2

예제 출력 2

impossible

예제 입력 3

1 5
0 0 6

예제 출력 3

5

힌트

In the first example, you can steal one art piece each with uplift $-2$, $0$ and $1$ respectively, two art pieces with uplift $-1$, and four art pieces with uplift $2$. This results in a total of $1 + 1 + 1 + 2 + 4 = 9$ stolen art pieces with a total uplift of $1 ⋅ (-2) + 1 ⋅ 0 + 1 ⋅ 1 + 2 ⋅ (-1) + 4 ⋅ 2 = 5$ as required.

In the second example, it is impossible to steal art pieces such that their total uplift is $5$.

채점 및 기타 정보

  • 예제는 채점하지 않는다.
  • 이 문제의 채점 우선 순위는 2이다.