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

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個,可以用6進制表示,然后5維DP~OK!

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

邊界條件: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 閱讀(559) 評論(0)  編輯 收藏 引用 所屬分類: USACO

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


<2009年8月>
2627282930311
2345678
9101112131415
16171819202122
23242526272829
303112345

常用鏈接

留言簿(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>
            精品成人在线观看| 亚洲午夜激情| 免费观看久久久4p| 鲁大师影院一区二区三区| 在线 亚洲欧美在线综合一区| 久久精品欧洲| 久久丁香综合五月国产三级网站| 欧美日韩国产区| 亚洲日本欧美| 亚洲九九爱视频| 国产精品成人播放| 欧美一级免费视频| 久久国产黑丝| 亚洲毛片播放| 亚洲视屏一区| 韩日欧美一区二区三区| 亚洲电影成人| 欧美性一区二区| 久久久99国产精品免费| 美女任你摸久久| 亚洲欧美日韩一区二区三区在线观看| 午夜日韩av| 亚洲美女尤物影院| 欧美一区二区三区免费观看| 亚洲经典在线| 亚洲欧美国产va在线影院| 在线免费观看日韩欧美| 一本久道久久久| 黄色亚洲在线| 亚洲视屏一区| 日韩亚洲国产欧美| 久久aⅴ国产欧美74aaa| 亚洲小说欧美另类社区| 久久免费国产| 欧美伊久线香蕉线新在线| 欧美xx视频| 久久裸体艺术| 国产精品盗摄久久久| 欧美国产日本| 国内揄拍国内精品少妇国语| 99综合视频| 亚洲精品中文字| 久久精品国产精品亚洲综合| 亚洲一区二区免费| 欧美激情 亚洲a∨综合| 久久久亚洲国产美女国产盗摄| 欧美美女福利视频| 亚洲成色777777在线观看影院| 国产日韩欧美一区二区| 一本色道88久久加勒比精品| 亚洲欧洲日本国产| 久久婷婷丁香| 老司机一区二区| 国产亚洲精品久久久久动| 中文成人激情娱乐网| 一本综合精品| 欧美精品福利视频| 亚洲高清影视| 亚洲经典在线| 欧美激情亚洲精品| 亚洲国产精品嫩草影院| 亚洲国产欧美日韩另类综合| 欧美在线观看一区二区| 欧美在线视频免费| 国产精品综合视频| 午夜精品网站| 久久久99国产精品免费| 国产综合激情| 久久久另类综合| 蜜桃av一区| 亚洲国产日韩欧美| 欧美高清在线精品一区| 亚洲国产精品久久91精品| 亚洲日本免费电影| 欧美日韩日本国产亚洲在线| 一本色道久久精品| 欧美一区二区视频在线| 国产婷婷色综合av蜜臀av| 欧美在线观看网址综合| 欧美成人免费一级人片100| 亚洲精品老司机| 欧美久久久久免费| 亚洲一级在线观看| 久久久噜噜噜久久狠狠50岁| 国内久久婷婷综合| 免费在线看一区| 亚洲精品国产无天堂网2021| 亚洲亚洲精品在线观看 | 久久亚洲风情| 在线观看欧美激情| 欧美精品免费在线| 亚洲一区999| 浪潮色综合久久天堂| 亚洲国产人成综合网站| 欧美日韩在线另类| 先锋a资源在线看亚洲| 美女精品在线| 亚洲女同同性videoxma| 国内成+人亚洲| 欧美成人自拍| 欧美一区1区三区3区公司| 欧美成人激情视频| 亚洲欧美国产高清va在线播| 狠狠做深爱婷婷久久综合一区| 女同一区二区| 香蕉国产精品偷在线观看不卡 | 午夜精品福利在线观看| 韩国久久久久| 欧美日韩一区在线观看视频| 久久国产手机看片| 日韩系列在线| 蜜臀久久99精品久久久久久9| 妖精成人www高清在线观看| 国产日韩精品久久| 欧美日韩一区二区在线播放| 久久成人一区二区| 亚洲中午字幕| 最新日韩在线| 免费在线观看一区二区| 性久久久久久久久久久久| 亚洲精品国产无天堂网2021| 国产日韩精品一区二区三区在线 | 午夜精品视频网站| 亚洲精品一区在线观看| 欧美激情第二页| 久久综合狠狠综合久久激情| 亚洲欧美另类在线| 夜夜嗨一区二区| 亚洲日本视频| 在线国产精品一区| 红桃视频欧美| 国产一区二区毛片| 国产精品综合久久久| 国产精品成人一区二区三区吃奶 | 午夜激情综合网| 一本久道久久久| 日韩一级免费| 亚洲毛片av在线| 亚洲麻豆av| 在线视频日韩精品| 日韩一区二区电影网| 日韩一本二本av| 亚洲日本视频| 日韩午夜中文字幕| 亚洲美女啪啪| 宅男精品导航| 亚洲一区二区视频在线| 亚洲一区二区三区乱码aⅴ| 99视频一区二区| 亚洲视频二区| 亚洲欧美在线播放| 欧美有码在线观看视频| 久久青青草综合| 欧美成人在线影院| 欧美激情无毛| 国产精品男gay被猛男狂揉视频| 国产精品白丝av嫩草影院| 国产精品久久久久久久久久妞妞 | 国产欧美成人| 国产自产v一区二区三区c| 激情久久一区| 亚洲伦理网站| 亚洲欧美成人综合| 久久精品首页| 欧美成人在线影院| 亚洲另类黄色| 亚久久调教视频| 麻豆国产精品va在线观看不卡| 免费日韩精品中文字幕视频在线| 欧美大片免费久久精品三p| 欧美喷水视频| 国产女主播一区二区| 国产在线视频欧美| 亚洲免费精彩视频| 欧美制服丝袜| 亚洲国产一区二区三区a毛片| 日韩手机在线导航| 欧美影院成人| 欧美日本在线| 国内精品伊人久久久久av一坑| 亚洲精品乱码久久久久久蜜桃麻豆| 亚洲视频在线一区| 免费成人高清在线视频| 99精品视频免费观看视频| 性色av一区二区三区在线观看| 免费在线播放第一区高清av| 国产精品区一区二区三区| 伊人久久亚洲影院| 亚洲欧美资源在线| 亚洲电影免费观看高清完整版在线| 99天天综合性| 美女国产一区| 国产亚洲欧美一级| 亚洲天堂av图片| 免费国产自线拍一欧美视频| 亚洲无亚洲人成网站77777| 噜噜噜在线观看免费视频日韩| 国产欧美一区二区精品性 | 伊人久久亚洲美女图片| 亚洲一区二区四区|