Knjige
시간 제한1초메모리 제한1024 MB
책을 왼쪽부터 읽으며 각 책을 a분 동안 전체를 읽거나 b분 동안 겉표지만 읽을 때, t분 안에 전체를 읽은 책들의 매력도 합의 최댓값을 구한다.
문제
Marko was at the Interliber book fair, and he bought books. The attraction of the -th book is . 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 minutes reading.
For each book, he can either read it in its entirety, which takes him minutes; or read only the content from the covers, which takes him 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 minutes?
Note: If Marko starts reading a book but fails to finish it before the end of minutes, that book does not contribute to his inspiration.
입력
The first line contains integers , , and (, , ), 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 integers (, ), the attraction values of books.
출력
In the first and only line print Mirko’s maximal inspiration after minutes.