Problem
Shopping Offers
Description
In a shop each kind of product has a price. For example, the price of a flower is ICU (Informatics Currency Units) and the price of a vase is ICU. In order to attract more customers, the shop introduces some special offers.
A special offer consists of one or more product items for a reduced price. Examples: three flowers for ICU instead of , or two vases together with one flower for ICU instead of .
Write a program that calculates the price a customer has to pay for certain items, making optimal use of the special offers. That is, the price should be as low as possible. You are not allowed to add items, even if that would lower the price.
For the prices and offers given above, the (lowest) price for three flowers and two vases is ICU: two vases and one flower for the reduced price of ICU and two flowers for the regular price of ICU.
Input
Your program is to read from standard input. The first line contains the number of different kinds of products in the basket . Each of the next b lines contains three values , , and . The value is the (unique) product code . The value indicates how many items of this product are in the basket . The value p is the regular price per item . Notice that all together at most items can be in the basket. The line contains the number of special offers . Each of the next lines describes one offer by giving its structure and its reduced price. The first number n on such a line is the number of different kinds of products that are part of the offer . The next n pairs of numbers indicate that items with product code are involved in the offer. The last number on the line stands for the reduced price . The reduced price of an offer is less than the sum of the regular prices.
Output
Your program is to write to standard output. Output one line with the lowest possible price to be paid.
Sample Input
1  2 
Sample Output
1  14 
标签：五维DP
Translation
有至多五种物品，给出每一种物品的单价和几种套餐的价格，求买目标物品至少需要多少钱。
Solution
这是一道大水题。因为只有五种物品，可以用五维的来表示，五个维度分别表示五种物品的个数，即表示第一种物品取个，第二种物品取个……第五种物品取个至少需要多少钱。把每种物品的单价看作一种只有一个物品的套餐，这样枚举套餐，看能否转移。
Code
1 
