#P6538. [COCI 2013/2014 #1] LOPOV
[COCI 2013/2014 #1] LOPOV
Background
There are some items and a thief.
Problem Description
There are items. Each item has a weight and a value .
Mirko has bags. The maximum weight each bag can hold is .
Each bag can contain only one item. What is the maximum total value of items that can be taken?
Input Format
The first line contains two positive integers and .
Each of the next lines contains two positive integers and .
Each of the next lines contains one positive integer .
Output Format
Output one line: the maximum total value of the items that can be taken.
2 1
5 10
100 100
11
10
3 2
1 65
5 23
2 99
10
2
164
Hint
Constraints
- .
- .
- .
Explanation for Sample 2
Mirko puts the first item into the second bag, and the third item into the first bag.
Notes
This problem is translated from COCI2013-2014 CONTEST #1 T4 LOPOV.
Translated by ChatGPT 5