#P13847. [CERC 2023] Cakes
[CERC 2023] Cakes
题目描述
Your local cake shop is making a business plan for the next few months. The bakers have different recipes, each requiring their own set of ingredients and tools. During the baking, the ingredients are consumed, but the tools are not and can be reused for other recipes. Currently, the bakery has no ingredients or tools – they were all destroyed in the recent floods or taken away by the tax bureau.
The son of the main chef managed to convince everyone to only bake each type of cake once. Individuals on the internet are supposedly happy to pay extra to be the only owners of their own unique Nutty-Fudge Tart (NFT). In fact, the son has already gone ahead and estimated how much money they can earn for each type of cake. Now bakers are looking at each other, trying to figure out which types of cake to prepare for maximum profit. You are given the costs of all ingredients, tools, and prices of cakes. Your task is to determine how much profit the bakers can make.
输入格式
The first line contains three integers: , , and , the number of ingredients, the number of recipes, and the number of different tools in them, respectively. The second line contains space-separated integers , the prices of each cake. The third line contains space-separated integers , representing the prices of each ingredient. The fourth line contains space-separated integers , representing the prices of all tools.
This is followed by lines, each containing space-separated integers , corresponding to the amount of ingredient in cake .
Finally, this is followed by lines of the following format: the -th row starts with an integer , the number of tools required for -th cake. This is followed by space-separated integers , indicating that we need tool to prepare cake (listed tools are distinct).
输出格式
Print a single number: the maximum profit that the cake shop can make.
5 3 4
14 18 21
1 2 3 1 2
5 6 3 10
0 0 1 2 0
1 2 0 1 2
5 2 1 0 0
2 1 2
2 2 3
2 3 4
3
提示
Comment
The maximum profit is made by baking cakes 1 and 2, but not cake 3.