Logo
(追記) (追記ここまで)

25261번 - Uplifting Excursion 서브태스크다국어

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

문제

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 2ドルM + 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ドル$.

출처

Olympiad > Baltic Olympiad in Informatics > BOI 2022 C번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
  • 이 문제의 채점 우선 순위는 2이다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /