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

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!

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

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

狀態轉移方程:
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 閱讀(551) 評論(0)  編輯 收藏 引用 所屬分類: USACO

只有注冊用戶登錄后才能發表評論。
網站導航: 博客園   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>
            欧美一区二区私人影院日本| 1024成人网色www| 一个色综合av| 一本久久精品一区二区| 欧美日产国产成人免费图片| 一区二区国产日产| 在线视频你懂得一区| 国产精品区免费视频| 久久精品理论片| 久久久精品一区| 亚洲欧洲在线一区| 99精品国产热久久91蜜凸| 国产精品视频久久| 蜜臀a∨国产成人精品| 欧美成人免费va影院高清| 亚洲一区二区不卡免费| 欧美一级片在线播放| 亚洲精品1区| 亚洲视频一区二区在线观看| 国产亚洲精品久久久| 亚洲电影免费观看高清完整版在线| 欧美成人精品激情在线观看| 亚洲女ⅴideoshd黑人| 久久精品首页| 亚洲视频一区二区在线观看| 午夜国产精品视频免费体验区| 狠狠狠色丁香婷婷综合激情| 亚洲欧洲精品一区二区三区不卡 | 麻豆九一精品爱看视频在线观看免费| 久久这里有精品15一区二区三区| 99国产精品99久久久久久| 亚洲欧美日本视频在线观看| 亚洲麻豆av| 久久福利毛片| 亚洲欧美日本国产有色| 欧美jizz19hd性欧美| 欧美一区二区三区四区夜夜大片| 欧美大尺度在线| 久久久久久久波多野高潮日日| 欧美激情五月| 欧美大尺度在线观看| 国产伦一区二区三区色一情| 亚洲美女福利视频网站| 尤物九九久久国产精品的特点| 中文一区字幕| 日韩一区二区精品视频| 久久久夜精品| 久久久久久夜| 国产日韩精品在线播放| 亚洲调教视频在线观看| av成人激情| 欧美高清在线播放| 欧美韩日高清| 一区二区在线视频| 欧美在线一级视频| 久久精品99久久香蕉国产色戒| 国产精品video| 一本色道久久加勒比精品| av不卡在线观看| 欧美日韩免费观看一区三区| 91久久在线| 99精品99| 欧美绝品在线观看成人午夜影视| 欧美黄色影院| 日韩午夜激情| 欧美美女福利视频| 亚洲毛片在线| 亚洲综合视频一区| 国产精品入口尤物| 亚洲一区二区三区四区中文| 亚洲欧美美女| 国产私拍一区| 久久精品国产综合精品| 免费不卡在线视频| 亚洲国语精品自产拍在线观看| 欧美 日韩 国产 一区| 亚洲成人中文| 在线午夜精品| 国产精品扒开腿爽爽爽视频| 亚洲欧美日韩视频二区| 久久久久一区二区三区四区| 在线成人中文字幕| 欧美激情综合| 亚洲尤物精选| 美女露胸一区二区三区| 亚洲乱码国产乱码精品精天堂| 欧美激情综合色| 在线亚洲欧美专区二区| 久久九九精品| 亚洲国产一成人久久精品| 欧美日韩午夜激情| 香蕉乱码成人久久天堂爱免费| 久久亚洲色图| 中文成人激情娱乐网| 国产亚洲欧美另类中文| 你懂的视频一区二区| 亚洲视频成人| 免费中文日韩| 性欧美xxxx大乳国产app| 在线观看欧美日韩国产| 国产精品v亚洲精品v日韩精品 | 久久er精品视频| 91久久久久久久久| 久久久久久久久岛国免费| 亚洲美女免费视频| 国产亚洲欧美日韩美女| 欧美乱在线观看| 久久精品国产99国产精品| 亚洲人成人一区二区在线观看| 欧美一区二区三区免费观看| 亚洲人成欧美中文字幕| 国产一区二区精品久久91| 欧美激情亚洲另类| 久久国产视频网| 亚洲视频一区在线观看| 亚洲国产天堂网精品网站| 久久久7777| 亚洲在线一区| 99精品视频免费全部在线| 激情91久久| 国产伦精品一区二区三| 欧美日韩在线电影| 欧美不卡在线视频| 久久―日本道色综合久久| 亚洲欧美激情四射在线日 | 久久久欧美精品| 亚洲在线一区二区三区| 夜夜嗨av一区二区三区| 在线看片第一页欧美| 国产亚洲aⅴaaaaaa毛片| 国产精品啊v在线| 欧美日韩在线大尺度| 欧美激情一区在线| 欧美成人r级一区二区三区| 久久亚洲综合色| 久久久福利视频| 久久精品国产99精品国产亚洲性色| 亚洲一区二区三区精品在线 | 男男成人高潮片免费网站| 久久精品人人爽| 欧美中文在线观看| 久久精品日韩欧美| 久久精品卡一| 久久综合色一综合色88| 久久婷婷人人澡人人喊人人爽| 久久久久亚洲综合| 久久一区二区三区国产精品| 久久躁日日躁aaaaxxxx| 久久日韩粉嫩一区二区三区| 久久免费视频网| 老司机一区二区三区| 欧美不卡在线视频| 亚洲国产成人久久| 日韩视频一区| 亚洲一区二区视频| 久久成人18免费观看| 久久久不卡网国产精品一区| 麻豆精品传媒视频| 欧美精品91| 国产精品久久久久99| 国产视频一区在线观看一区免费| 国产精品一区2区| 精品av久久707| 亚洲久久视频| 午夜精品三级视频福利| 久久免费视频这里只有精品| 欧美成人激情视频免费观看| 亚洲人成艺术| 亚洲免费视频网站| 老牛影视一区二区三区| 欧美日韩国产一区精品一区| 欧美亚男人的天堂| 黄色成人av网站| 一区二区久久久久久| 欧美一区二区三区免费在线看| 久久综合伊人77777| 亚洲免费久久| 久久精品国产亚洲精品| 欧美连裤袜在线视频| 国产亚洲成人一区| 日韩香蕉视频| 久久手机免费观看| 亚洲久久一区| 久久漫画官网| 国产精品视频网| 亚洲日本成人| 久久gogo国模啪啪人体图| 亚洲国产成人av在线| 亚洲欧美日韩一区二区三区在线观看| 久久久中精品2020中文| 欧美午夜电影在线观看| 亚洲国产另类精品专区| 欧美一区二区女人| 亚洲精品无人区| 久久影视三级福利片| 国产精品视频yy9099| 一本色道久久综合亚洲精品小说| 久久亚洲美女| 香蕉久久夜色精品| 国产精品午夜电影|