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

31679번 - Knjige 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB72444159.420%

문제

Marko was at the Interliber book fair, and he bought $n$ books. The attraction of the $i$-th book is $k_i$. Marko arranged the books on the shelf according to their attraction values, so the first book from the left is the least attractive, and every next one to the right is more or equally attractive than the previous one.

It has been quite some time since Interliber, but Marko has only now found time to read the books. He will spend a total of $t$ minutes reading.

For each book, he can either read it in its entirety, which takes him $a$ minutes; or read only the content from the covers, which takes him $b$ minutes.

He will start from the leftmost book. After finishing the current book (either entirely or just the content from the covers), he moves on to the next book, which is the first one to the right of the book he just read. Marko’s inspiration is equal to the sum of the attraction values of the books he has read in their entirety. What is the maximum value of Marko’s inspiration after $t$ minutes?

Note: If Marko starts reading a book but fails to finish it before the end of $t$ minutes, that book does not contribute to his inspiration.

입력

The first line contains integers $n,ドル $t,ドル $a$ and $b$ (1ドル ≤ n ≤ 2 \cdot 10^5,ドル 1ドル ≤ t ≤ 10^9,ドル 1ドル ≤ b < a ≤ 10^9$), the number of books, the time Marko will spend reading, time required for reading a book and the time required to read the content from the covers.

The second line contains $n$ integers $k_i$ (1ドル ≤ k_i ≤ 10^9,ドル $k_i ≤ k_{i+1}$), the attraction values of books.

출력

In the first and only line print Mirko’s maximal inspiration after $t$ minutes.

제한

서브태스크

번호배점제한
17

$k_i = k_{i+1}$ for each $i = 1, \dots , n - 1$

227

$n ≤ 1,円 000$

336

No additional constraints.

예제 입력 1

3 5 2 1
2 2 4

예제 출력 1

6

For example, Marko can read the first book in its entirety, read only the content from the covers of the second book, and read the third book in its entirety, thus achieving the maximum possible inspiration.

예제 입력 2

2 10 3 1
3 3

예제 출력 2

6

예제 입력 3

4 10 3 2
3 4 5 6

예제 출력 3

12

힌트

출처

Contest > Croatian Open Competition in Informatics > COCI 2023/2024 > Contest #4 2번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

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

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