青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

posts - 12,  comments - 16,  trackbacks - 0
  
Shopping Offers
IOI'95

In a certain shop, each kind of product has an integer price. For example, the price of a flower is 2 zorkmids (z) and the price of a vase is 5z. In order to attract more customers, the shop introduces some special offers.

A special offer consists of one or more product items together for a reduced price, also an integer. Examples:

  • three flowers for 5z instead of 6z, or
  • two vases together with one flower for 10z instead of 12z.

Write a program that calculates the price a customer has to pay for a purchase, making optimal use of the special offers to make the price 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 14z: two vases and one flower for the reduced price of 10z and two flowers for the regular price of 4z.

PROGRAM NAME: shopping

INPUT FORMAT

The input file has a set of offers followed by a purchase.
Line 1: s, the number of special offers, (0 <= s <= 99).
Line 2..s+1: Each line describes an offer using several integers. The first integer is n (1 <= n <= 5), the number of products that are offered. The subsequent n pairs of integers c and k indicate that k items (1 <= k <= 5) with product code c (1 <= c <= 999) are part of the offer. The last number p on the line stands for the reduced price (1 <= p <= 9999). The reduced price of an offer is less than the sum of the regular prices.
Line s+2: The first line contains the number b (0 <= b <= 5) of different kinds of products to be purchased.
Line s+3..s+b+2: Each of the subsequent b lines contains three values: c, k, and p. The value c is the (unique) product code (1 <= c <= 999). The value k indicates how many items of this product are to be purchased (1 <= k <= 5). The value p is the regular price per item (1 <= p <= 999). At most 5*5=25 items can be in the basket.

SAMPLE INPUT (file shopping.in)

2
1 7 3 5
2 7 1 8 2 10
2
7 3 2
8 2 5

OUTPUT FORMAT

A single line with one integer: the lowest possible price to be paid for the purchases.

SAMPLE OUTPUT (file shopping.out)

14

解答:
0 <= b <= 5,1 <= k <= 5,可用5*5*5*5*5的DP 每種買0~5個(gè),可以用6進(jìn)制表示,然后5維DP~OK!

狀態(tài)設(shè)置:F[a1][a2][a3][a4][a5]為買a1件物品1,a2件物品2,a3件物品3,a4件物品4,a5件物品5時(shí),所需的最少價(jià)格

邊界條件:F[0][0][0][0][0]=0;

狀態(tài)轉(zhuǎn)移方程:
F[a1][a2][a3][a4][a5]=min{F[ a1-P[i][1] ][ a2-P[i][2] ][ a3-P[i][3] ][ a4-P[i][4] ][ a5-P[i][5] ]+P[i][0]}
其中i=1..s+b; 且 ak-p[i][k]>=0

/*
ID: kuramaw1
PROG: shopping
LANG: C++
*/

#include 
<fstream>
#include 
<cstring>


using std::ifstream;
using std::ofstream;
using std::endl;

#define  MAX_T(a,b) ((a)>(b)?(a):(b))

#define  MAX 5
#define  MAX_S 100

int f[MAX+1][MAX+1][MAX+1][MAX+1][MAX+1];//min price

short s,b;
short s_p[MAX_S],component[MAX_S][MAX],p_num[MAX],p[MAX],p_t(0),order[MAX];

inline 
short product_code_to_order(short code)
{
    
for(int i=0;i<p_t;i++)
     
if(p_num[i]==code)
         
return i;
    p_num[p_t
++]=code;
    
return (p_t-1);

}

int main()
{
    ifstream 
in("shopping.in");
    
in>>s;
    memset(component,
0,sizeof(component));
    
for(int i=0;i<s;i++)
    {
        
short n;
        
in>>n;
        
for(int j=0;j<n;j++)
        {
            
short c,k;
            
in>>c>>k;
            component[i][product_code_to_order(c)]
=k;
        }
        
in>>s_p[i];
            
    }

    memset(order,
0,sizeof(order));
    memset(p,
0,sizeof(p));
    
in>>b;
    
for(int i=0;i<b;i++)
    {
        
short c,k,p1;
        
in>>c>>k>>p1;
        
short n=product_code_to_order(c);
        order[n]
=k;
        p[n]
=p1;
    }
    
in.close();

    
//do dp
    short ii[MAX];
#define loop(i)  for(ii[i]=0;ii[i]<=order[i];ii[i]++)
#define  F(a) f[a[0]][a[1]][a[2]][a[3]][a[4]]
    
    loop(
0) loop(1) loop(2) loop(3) loop(4)
    {

        F(ii)
=ii[0]*p[0]+ii[1]*p[1]+ii[2]*p[2]+ii[3]*p[3]+ii[4]*p[4];
        
for(short j=0;j<s;j++)
        {
            
short t[MAX];
            
for(short k=0;k<5;k++)
                t[k]
=MAX_T(0,ii[k]-component[j][k]);
            
if(F(t)+s_p[j]<F(ii))
                F(ii)
=F(t)+s_p[j];

        }
    }

    
//out
    ofstream out("shopping.out");
    
out<<F(order)<<endl;
    
out.close();


}


posted on 2009-08-13 11:46 kuramawzw 閱讀(522) 評論(0)  編輯 收藏 引用 所屬分類: USACO

只有注冊用戶登錄后才能發(fā)表評論。
網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


<2025年9月>
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

常用鏈接

留言簿(5)

隨筆分類

隨筆檔案

文章檔案

Algorithm

搜索

  •  

最新評論

閱讀排行榜

評論排行榜

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            欧美国产视频在线| 欧美国产精品劲爆| 久久精品国产99国产精品| 91久久久国产精品| 亚洲欧洲在线视频| 亚洲人体大胆视频| 99视频热这里只有精品免费| 一区二区三区福利| 午夜亚洲影视| 毛片av中文字幕一区二区| 欧美成人一区二免费视频软件| 蜜桃av噜噜一区二区三区| 欧美成人免费一级人片100| 亚洲国产精品一区在线观看不卡| 麻豆国产精品一区二区三区 | 久久国产一区二区三区| 亚洲一区二区四区| 欧美在线啊v| 免费不卡在线观看av| 亚洲精品乱码久久久久久| 亚洲一区免费| 久久综合九色欧美综合狠狠| 欧美日本韩国一区二区三区| 国产精品爽爽ⅴa在线观看| 红桃视频一区| 亚洲一区二区三区四区视频| 久久视频在线看| 亚洲美女在线一区| 久久国产精品99久久久久久老狼 | 久久久www| 亚洲精品美女免费| 性欧美8khd高清极品| 欧美1级日本1级| 国产三级精品在线不卡| 亚洲免费电影在线| 老司机午夜精品视频在线观看| 亚洲区欧美区| 久久久水蜜桃| 国产精品亚洲人在线观看| 亚洲麻豆av| 欧美第一黄网免费网站| 亚洲欧美激情在线视频| 欧美日韩成人综合在线一区二区| 狠狠干成人综合网| 亚洲欧美日韩在线综合| 亚洲国产欧美一区二区三区同亚洲| 亚洲欧美在线另类| 欧美日韩在线电影| 亚洲六月丁香色婷婷综合久久| 久久影院午夜论| 欧美一级视频| 国产欧美日韩激情| 亚洲香蕉视频| 亚洲精品一区在线观看| 免费在线观看精品| 亚洲第一在线综合网站| 久久久久久黄| 欧美在线观看网址综合| 国产伦精品一区二区三区照片91| 亚洲一区二区三区四区五区午夜| 亚洲精品国产精品国自产在线 | 亚洲欧美激情精品一区二区| 欧美美女操人视频| 亚洲欧美国产制服动漫| 亚洲一区在线免费观看| 国产精品a级| 亚洲综合色丁香婷婷六月图片| 亚洲精品欧美日韩| 欧美日韩国产欧| 一区二区日韩伦理片| 亚洲伦理在线观看| 国产精品videosex极品| 午夜欧美不卡精品aaaaa| 亚洲综合欧美日韩| 好吊色欧美一区二区三区四区 | 亚洲看片网站| 欧美深夜影院| 欧美在线啊v一区| 久久国产精品久久久久久| 黄色一区二区三区四区| 欧美国产在线视频| 欧美精品一区二| 亚洲一区二区三区精品在线| 亚洲一区二区三区四区视频| 国产亚洲观看| 欧美bbbxxxxx| 欧美人与禽性xxxxx杂性| 亚洲一区二区三区视频播放| 性娇小13――14欧美| 亚洲精品国产精品乱码不99| 亚洲免费精品| 国产偷自视频区视频一区二区| 免费在线亚洲| 欧美视频久久| 久久婷婷国产综合精品青草| 欧美福利精品| 欧美一区二区视频在线观看| 久久夜色精品国产亚洲aⅴ| 一道本一区二区| 欧美一区激情| 在线视频亚洲欧美| 久久久久青草大香线综合精品| 亚洲人在线视频| 亚洲欧美日韩在线观看a三区| 亚洲欧洲在线看| 欧美在线国产| 亚洲欧美国产精品专区久久| 久久久久久久综合日本| 性久久久久久久久久久久| 欧美成人免费大片| 久久精选视频| 国产精品二区在线| 亚洲国产欧美日韩| 精品福利电影| 午夜精品在线视频| 一本大道久久a久久综合婷婷| 久久国产黑丝| 久久国产精品99久久久久久老狼| 欧美精品v国产精品v日韩精品| 久久久久久久久久久久久女国产乱 | 美国十次了思思久久精品导航| 中文精品视频一区二区在线观看| 狠狠入ady亚洲精品经典电影| 日韩视频不卡| 亚洲精品社区| 久久久久久有精品国产| 欧美在线视频观看| 欧美三级乱码| 亚洲精品自在在线观看| 亚洲欧洲一区二区在线播放 | 亚洲欧洲av一区二区| 亚洲一区视频在线| 欧美日韩精品免费观看视频完整| 欧美不卡三区| 亚洲成人在线视频播放| 久久国产成人| 美女久久一区| 在线观看欧美一区| 久久综合一区| 欧美国产91| 最新成人在线| 欧美高清视频一区二区三区在线观看 | 性伦欧美刺激片在线观看| 欧美伊人久久久久久午夜久久久久| 欧美视频在线免费| 一本色道久久综合亚洲精品按摩 | 久久精品综合| 尤物yw午夜国产精品视频| 久久激情一区| 欧美xart系列高清| 亚洲麻豆一区| 国产精品v亚洲精品v日韩精品| 一本一本a久久| 欧美一区二区三区婷婷月色| 国产色产综合产在线视频| 欧美在线精品免播放器视频| 免费亚洲电影在线| 亚洲人成人一区二区三区| 欧美激情欧美狂野欧美精品| 亚洲国产精品久久久久| 国产精品99久久久久久久女警 | 久久亚洲精品欧美| 亚洲国产小视频| 欧美日韩国产影片| 亚洲综合999| 欧美成人dvd在线视频| 日韩视频一区二区在线观看| 国产精品国产三级欧美二区| 香蕉成人久久| 亚洲国产高清在线| 午夜一区二区三视频在线观看| 亚洲成人直播| 国产精品日韩欧美综合| 免费影视亚洲| 欧美一级久久久久久久大片| 亚洲国产欧美精品| 久久九九国产精品| 亚洲性感美女99在线| 一区在线视频观看| 国产精品久久久久久久久久三级 | 久久精品国产免费观看| 亚洲激情婷婷| 国产精品久久久久99| 久久精品青青大伊人av| 亚洲国产精品电影| 久久精品99| 亚洲天堂av图片| 在线观看日韩国产| 国产精品羞羞答答| 欧美日韩国产小视频在线观看| 欧美一区二区在线免费观看| 日韩视频免费看| 男男成人高潮片免费网站| 午夜激情一区| 一本久道久久久| 亚洲精品免费一区二区三区| 国内一区二区在线视频观看| 国产精品国产三级国产aⅴ入口 | 亚洲国产精品悠悠久久琪琪| 国产三级精品三级|