#P2732. [USACO3.3] 商店购物 Shopping Offers
[USACO3.3] 商店购物 Shopping Offers
Description
Promotions bundle one or more products and sell them at a discount. For example:
Three flowers cost instead of , and vases plus flower cost instead of . Write a program to compute the cost for a customer to buy certain products, using the offers to minimize the total cost. Even if adding extra products could lower the total cost, you are not allowed to do that.
For the products above, the minimum cost to buy three flowers and two vases is: buy the offer of two vases and one flower for , and buy two flowers at the regular price for .
Input Format
The input file contains some offers provided by the store, followed by a shopping list (at most types of products).
Line : The number of offer types ().
Lines to : Each line describes one offer using several integers. The first integer () is the number of different products in this offer. Then there are pairs of integers and , meaning () units of the product with code () are included in this offer. The last integer is the offer price (). The offer price is always lower than the regular price.
Line : An integer (), the number of different products to buy.
Lines to : Each of these lines contains three integers . Here is the unique product code (), is the required quantity of product (), and is the regular price of product (). In total, at most items are to be purchased.
Output Format
Output a single line with one integer: the minimum total price to purchase these items.
2
1 7 3 5
2 7 1 8 2 10
2
7 3 2
8 2 5
14
Hint
Translation from NOCOW.
USACO Training Section 3.3.
Translated by ChatGPT 5
京公网安备 11011102002149号