#CT0000150. Túi sách kiến thức (Knowledge Book Bag)
Bài tập này chưa được xếp vào lộ trình.
Mục lục đề ⌄
Túi sách kiến thức (Knowledge Book Bag)
Knowledge Book Bag
Version: Phuoc Hung OJ Extended
Problem Statement

For an extracurricular trip, Minh can choose from available books. Book has a positive integer weight and provides knowledge points. Minh's bag can carry a total weight of at most .
Each book may be selected at most once. Choosing no books is allowed.
The primary goal is to maximize the total knowledge points. Among selections with the same maximum total, Minh prefers the one with the fewest books. The chosen book indices need not be printed.
Find the maximum total knowledge points and the minimum number of books among selections attaining that maximum.
Input
The first line contains two positive integers and .
Each of the next lines contains positive integers and , the weight and knowledge value of book .
Output
Print two integers on one line: the maximum total knowledge points and the minimum number of books among selections achieving that value. If no book fits, print 0 0.
Subtasks
- Subtask 1 (30 points): ; ; and for every .
- Subtask 2 (30 points): ; ; and for every .
- Subtask 3 (40 points): ; ; and for every .
Examples
Example 1
Input
4 7
3 6
4 8
7 14
2 3
Output
14 1
Explanation
Book has weight and value , so it fits. Books and also fit together () and yield , but use two books. No feasible selection exceeds points. The tie-break selects one book, yielding 14 1.
Example 2
Input
3 5
2 4
3 5
4 7
Output
9 2
Explanation
Selecting books and uses weight and provides . Book provides , but cannot be combined with either other book without exceeding weight . Therefore the optimum is points using books.
Example 3
Input
3 2
3 5
4 100
5 1
Output
0 0
Explanation
The capacity is , but the three books weigh , each exceeding the capacity. Minh chooses no books; both total value and count are .
Liên quan
Trong các cuộc thi sau: