7066.Book Shop II

Time Limit: 1s Memory Limit: 512MB

You are in a book shop which sells $n$ different books. You know the price, the number of pages and the number of copies of each book.

You have decided that the total price of your purchases will be at most $x$ . What is the maximum number of pages you can buy? You can buy several copies of the same book.

Input Format(From the terminal/stdin)

The first input line contains two integers $n$ and $x$ : the number of book and the maximum total price.

The next line contains $n$ integers $h_1,h_2,\ldots,h_n$ : the price of each book.

The next line contains $n$ integers $s_1,s_2,\ldots,s_n$ : the number of pages of each book.

The last line contains $n$ integers $k_1,k_2,\ldots,k_n$ : the number of copies of each book.

  • $1 \le n \le 100$
  • $1 \le x \le 10^5$
  • $1 \le h_i, s_i, k_i \le 1000$

Output Format(To the terminal/stdout)

Print one integer: the maximum number of pages.

Sample Input

Copy
3 10
2 6 3
8 5 4
3 5 2
 ·  \n
 · · \n
 · · \n
 · · \n

Sample Output

Copy
28
  \n

You can buy three copies of book 1 and one copy of book 3. The price is $3 \cdot 2 + 3 = 9$ and the number of pages is $3 \cdot 8 + 4 = 28$ .

Source: CSES, Additional Problems II, 1159

Submit

请先 登录

© 2025 FAQs