#P6646. [CCO 2020] Shopping Plans
[CCO 2020] Shopping Plans
Description
There are items. Each item has a type and a price .
For type , you must buy a number of items within , meaning you must buy at least items and at most items of this type.
You need to output the costs of the cheapest plans. If no such plan exists, output -1.
In particular, if two plans have the same total cost but are different in the specific set of chosen items, they are considered two different plans.
Input Format
The first line contains three integers .
The next lines each contain two integers .
The next lines each contain two integers .
Output Format
Output lines. Each line contains one integer. The -th line represents the cost of the -th cheapest plan.
5 2 7
1 5
1 3
2 3
1 6
2 1
1 1
1 1
4
6
6
7
8
9
-1
Hint
Sample Explanation
There are items and types.
Type : , type : .
Both type and type can only choose one item.
For the cheapest plan, choose .
And so on.
Subtasks
This problem uses bundled testdata.
- Subtask 1 ( points): , .
- Subtask 2 ( points): , .
- Subtask 3 ( points): .
- Subtask 4 ( points): .
- Subtask 5 ( points): No special restrictions.
For of the testdata, it is guaranteed that , , , .
Note
This problem is translated from Canadian Computing Olympiad 2020 Day 2 T3 Shopping Plans.
Translated by ChatGPT 5
京公网安备 11011102002149号