75 lines
4.8 KiB
HTML
75 lines
4.8 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
<!-- saved from url=(0055)http://olympiads.win.tue.nl/ioi/ioi95/contest/shop.html -->
|
|
<HTLM><HTML><HEAD><TITLE>IOI'95 Task: Shopping</TITLE>
|
|
<META http-equiv=Content-Type content="text/html; charset=gb2312">
|
|
<META content="MSHTML 6.00.2600.0" name=GENERATOR></HEAD>
|
|
<BODY background="IOI'95 Task Shopping.files/backgrnd.gif">
|
|
<H1><A href="http://olympiads.win.tue.nl/ioi/ioi95/index.html"><IMG
|
|
alt="[ IOI Home page ]" hspace=5 src="IOI'95 Task Shopping.files/logo.gif"
|
|
align=middle border=0></A> Task: Shopping Offers</H1><IMG alt=Tulip
|
|
src="IOI'95 Task Shopping.files/shop1.gif" align=bottom> =2, <IMG alt=Vase
|
|
src="IOI'95 Task Shopping.files/shop2.gif" align=bottom> =5, <IMG alt=Tulip
|
|
src="IOI'95 Task Shopping.files/shop1.gif" align=bottom> +<IMG alt=Tulip
|
|
src="IOI'95 Task Shopping.files/shop1.gif" align=bottom> +<IMG alt=Tulip
|
|
src="IOI'95 Task Shopping.files/shop1.gif" align=bottom> =5, <IMG alt=Vase
|
|
src="IOI'95 Task Shopping.files/shop2.gif" align=bottom> +<IMG alt=Vase
|
|
src="IOI'95 Task Shopping.files/shop2.gif" align=bottom> +<IMG alt=Tulip
|
|
src="IOI'95 Task Shopping.files/shop1.gif" align=bottom> =10, <IMG alt=Tulip
|
|
src="IOI'95 Task Shopping.files/shop1.gif" align=bottom> +<IMG alt=Tulip
|
|
src="IOI'95 Task Shopping.files/shop1.gif" align=bottom> +<IMG alt=Tulip
|
|
src="IOI'95 Task Shopping.files/shop1.gif" align=bottom> +<IMG alt=Vase
|
|
src="IOI'95 Task Shopping.files/shop2.gif" align=bottom> +<IMG alt=Vase
|
|
src="IOI'95 Task Shopping.files/shop2.gif" align=bottom> =?
|
|
<P>In a shop each kind of product has a price. For example, the price of a
|
|
flower is 2 ICU (Informatics Currency Units) and the price of a vase is
|
|
5 ICU. In order to attract more customers, the shop introduces some special
|
|
offers.
|
|
<P>A special offer consists of one or more product items for a reduced price.
|
|
Examples: three flowers for 5 ICU instead of 6, or two vases together
|
|
with one flower for 10 ICU instead of 12.
|
|
<P>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.
|
|
<P>For the prices and offers given above, the (lowest) price for three flowers
|
|
and two vases is 14 ICU: two vases and one flower for the reduced price of
|
|
10 ICU and two flowers for the regular price of 4 ICU.
|
|
<H2>Input Data</H2>The input data appears in two files: <TT>INPUT.TXT</TT> and
|
|
<TT>OFFER.TXT</TT>. The first file describes the purchases (in the `shopping
|
|
basket'). The second file describes the special offers. In both files, only
|
|
integers are used.
|
|
<P>The first line of <TT>INPUT.TXT</TT> contains the number <I>b</I> of
|
|
different kinds of products in the basket (0<=<I>b</I><=5). Each of the
|
|
next <I>b</I> lines contains three values <I>c</I>, <I>k</I>,
|
|
and <I>p</I>. The value <I>c</I> is the (unique) product code
|
|
(1<=<I>c</I><=999). The value <I>k</I> indicates how many items of
|
|
this product are in the basket (1<=<I>k</I><=5). The value <I>p</I>
|
|
is the regular price per item (1<=<I>p</I><=999). Notice that all together
|
|
at most 5*5=25 items can be in the basket.
|
|
<P>The first line of <TT>OFFER.TXT</TT> contains the number <I>s</I> of
|
|
special offers (0<=<I>s</I><=99). Each of the next <I>s</I> lines
|
|
describes one offer by giving its structure and its reduced price. The first
|
|
number <I>n</I> on such a line is the number of different kinds of products
|
|
that are part of the offer (1<=<I>n</I><=5). The next <I>n</I> pairs of
|
|
numbers (<I>c</I>,<I>k</I>) indicate that <I>k</I> items
|
|
(1<=<I>k</I><=5) with product code <I>c</I> (1<=<I>c</I><=999)
|
|
are involved in the offer. The last number <I>p</I> on the line stands for
|
|
the reduced price (1<=<I>p</I><=9999). The reduced price of an offer is
|
|
less than the sum of the regular prices.
|
|
<H2>Output Data</H2>Write to the output file <TT>OUTPUT.TXT</TT> one line with
|
|
the lowest possible price to be paid for the purchases in the input file.
|
|
<H2>Example Input and Output</H2>Figure 1 gives input and output files for
|
|
the example above. The product code of a flower is 7 and that of a vase
|
|
is 8.
|
|
<CENTER><PRE>
|
|
_____________ ________________ ______________
|
|
| INPUT.TXT | | OFFER.TXT | | OUTPUT.TXT |
|
|
|___________| |______________| |____________|
|
|
| 2 | | 2 | | 14 |
|
|
| 7 3 2 | | 1 7 3 5 | |____________|
|
|
| 8 2 5 | | 2 7 1 8 2 10 |
|
|
|___________| |______________|
|
|
</PRE>Figure 1: Example input and output </CENTER>
|
|
<HR>
|
|
<A href="mailto:ioi95@win.tue.nl">IOI 95</A> </BODY></HTML>
|