PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GD0000130. Phô mai cho bánh pizza (Cheese)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Phô mai cho bánh pizza (Cheese)
Cheese
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
There are types of cheese. Type has tastiness per gram and grams available. You may take any integer amount from to grams of each type, with total weight at most . Maximize total tastiness.
Input
The first line has . Each of the next lines contains .
Output
Print the maximum possible tastiness.
Subtasks
- Subtask 1 (20 points): ; ; ; .
- Subtask 2 (30 points): ; ; ; .
- Subtask 3 (50 points): ; ; ; .
Examples
Input
3 5
10 2
5 7
8 1
Output
38
Explanation
Take two grams of type one (), one gram of type three (), and two grams of type two (), for five grams and total tastiness .