PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GD0000239. Nhận dạng thuật toán: Chọn vật trong ba lô (Mixed Greedy Recognition 02)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Nhận dạng thuật toán: Chọn vật trong ba lô (Mixed Greedy Recognition 02)
Mixed Greedy Recognition 02
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
There are items. Item has weight and value . Your knapsack can carry total weight at most . Each item can be selected at most once and cannot be split.
Find the maximum total value of a feasible subset. You need not fill the capacity and may choose no items.
Input
- The first line contains .
- Each of the next lines contains for an item.
Output
Print the maximum total value that can be placed in the knapsack.
Subtasks
- Subtask 1 (20 points): ; ; ; .
- Subtask 2 (30 points): ; ; ; .
- Subtask 3 (50 points): ; ; ; .
Examples
Input
4 7
3 4
4 5
2 3
5 7
Output
10
Explanation
Items and have total weight and value . Items and also fit but give value . No feasible subset exceeds , so print .