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

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) 評(píng)論(0)  編輯 收藏 引用 所屬分類: USACO

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


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

常用鏈接

留言簿(5)

隨筆分類

隨筆檔案

文章檔案

Algorithm

搜索

  •  

最新評(píng)論

閱讀排行榜

評(píng)論排行榜

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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精品视频网| 日韩视频免费观看高清在线视频 | 久久久99精品免费观看不卡| 欧美视频免费在线观看| 亚洲国产成人tv| 亚洲国产成人一区| 久久久精品日韩| 久久久久综合| 激情视频一区| 久久九九免费| 亚洲午夜视频在线观看| 亚洲综合色在线| 欧美午夜激情视频| 亚洲一级片在线看| 先锋影音久久| 国产亚洲午夜高清国产拍精品| 亚洲一区二区三区四区中文| 性高湖久久久久久久久| 国产精品一区二区三区免费观看| 亚洲永久免费av| 久久精品视频99| 曰韩精品一区二区| 欧美波霸影院| 日韩亚洲成人av在线| 亚洲男人第一网站| 国产视频一区三区| 可以免费看不卡的av网站| 欧美激情精品久久久久久久变态| 亚洲精品国精品久久99热| 欧美绝品在线观看成人午夜影视| 日韩亚洲精品电影| 久久国产精品网站| 在线日韩成人| 欧美欧美在线| 亚洲欧美日韩精品久久亚洲区| 久久久午夜精品| 亚洲精品在线一区二区| 欧美日韩一区二区三| 香蕉尹人综合在线观看| 蜜臀99久久精品久久久久久软件 | 午夜日韩在线观看| 免费中文日韩| 亚洲午夜伦理| 精品1区2区3区4区| 欧美日韩国产不卡| 亚欧美中日韩视频| 亚洲高清在线观看| 亚洲欧美激情四射在线日| 国产一区二区av| 欧美精品激情blacked18| 亚洲午夜伦理| 亚洲福利视频网站| 校园春色综合网| 亚洲精品综合精品自拍| 国产乱子伦一区二区三区国色天香| 久久夜色精品国产亚洲aⅴ| 一本大道av伊人久久综合| 美国十次成人| 亚洲欧美日韩综合一区| 亚洲全部视频| 韩国欧美一区| 国产精品成人在线| 欧美xx视频| 欧美在线视频a| 在线亚洲自拍| 亚洲欧洲日本mm| 久色成人在线| 欧美在线综合| 亚洲一区二区在线看| 亚洲日本aⅴ片在线观看香蕉| 国产欧美一区二区三区另类精品| 欧美日韩国产精品一卡| 牛夜精品久久久久久久99黑人 | 一区二区三区毛片| 亚洲国产精品一区制服丝袜| 国产日韩精品一区二区三区在线| 欧美日韩国产综合视频在线观看| 久热国产精品| 久久精品首页| 欧美在线免费视屏| 亚洲免费在线| 亚洲午夜电影| 一区二区三区黄色| 日韩亚洲欧美在线观看| 亚洲黄色片网站| 欧美激情综合色| 免费在线看成人av| 久久精品电影| 欧美一区2区三区4区公司二百| 亚洲欧美日韩一区二区在线 | 一区二区动漫| 一本不卡影院| 日韩视频免费看| av不卡在线| 中文久久精品| 一区二区三区四区五区精品视频| 亚洲国产精品一区二区www| 在线精品一区二区| 一色屋精品视频在线看| 在线观看的日韩av| 亚洲缚视频在线观看| 在线国产日韩| 91久久精品美女| 日韩亚洲欧美一区| 一本色道88久久加勒比精品| 国产精品99久久久久久www| 一区二区精品在线| 亚洲一区二区精品在线| 性久久久久久| 久久久精彩视频| 美玉足脚交一区二区三区图片| 久久人人爽人人| 欧美高清视频免费观看| 亚洲高清在线视频| 一本色道婷婷久久欧美| 亚洲视频一区二区| 久久精品免费看| 久久亚洲精品伦理| 欧美日韩国产va另类| 国产精品性做久久久久久| 激情综合色综合久久综合| 在线亚洲美日韩| 亚洲午夜视频在线| 香蕉久久夜色精品国产| 久久免费黄色| 亚洲国产精品va在看黑人| 亚洲视频在线播放| 久久久久久久波多野高潮日日| 欧美搞黄网站| 国产日本欧美在线观看| 亚洲激情啪啪| 欧美一区二区三区的| 欧美成人a∨高清免费观看| 亚洲美女精品一区| 亚洲欧美日韩另类精品一区二区三区| 在线观看亚洲| 一区二区冒白浆视频| 久久国产日本精品| 亚洲黄色成人久久久| 午夜精品剧场| 欧美精品在线极品| 国精品一区二区三区| 一区二区三区四区五区精品视频 | 亚洲成人在线| 91久久精品国产91久久性色| 亚洲一区二区黄色| 欧美风情在线观看| 午夜精品视频在线| 欧美日韩免费在线| 亚洲大胆美女视频| 欧美一级视频一区二区| 亚洲国产色一区| 久久精品视频va| 国产精品video| 日韩系列欧美系列| 欧美成人日本| 久久精品99国产精品酒店日本| 欧美日韩在线不卡| 亚洲精品一区在线观看香蕉| 久久午夜精品| 亚洲欧美国产日韩天堂区| 欧美日韩高清在线一区| 亚洲国产欧美日韩精品| 久久免费视频这里只有精品| 亚洲免费小视频| 欧美午夜精品| 亚洲午夜视频在线观看| 亚洲精品一区二区三区四区高清| 麻豆国产va免费精品高清在线| 国产一区二区三区在线观看免费| 午夜在线视频观看日韩17c| 亚洲国产三级在线| 亚洲一区二区精品在线| 久久在线免费观看视频| 亚洲欧美日本伦理| 欧美三区不卡| 亚洲图片激情小说| 亚洲最黄网站| 欧美视频中文在线看| 亚洲一区二区三区在线| 久久久av网站| 国产日韩亚洲欧美| 久久精品一区中文字幕| 亚洲欧美久久久| 国产精品一区久久| 欧美在线观看天堂一区二区三区| 国产精品一二三| 香蕉久久精品日日躁夜夜躁| 亚洲欧美日本精品| 国产一区欧美日韩| 米奇777超碰欧美日韩亚洲| 久久久久久久久久久久久久一区| 樱桃国产成人精品视频| 欧美激情网友自拍| 欧美精品一区二区三区久久久竹菊 | 女人天堂亚洲aⅴ在线观看| 老司机亚洲精品|