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

POJ 1157 LITTLE SHOP OF FLOWERS 動態規劃

Description

You want to arrange the window of your flower shop in a most pleasant way. You have F bunches of flowers, each being of a different kind, and at least as many vases ordered in a row. The vases are glued onto the shelf and are numbered consecutively 1 through V, where V is the number of vases, from left to right so that the vase 1 is the leftmost, and the vase V is the rightmost vase. The bunches are moveable and are uniquely identified by integers between 1 and F. These id-numbers have a significance: They determine the required order of appearance of the flower bunches in the row of vases so that the bunch i must be in a vase to the left of the vase containing bunch j whenever i < j. Suppose, for example, you have bunch of azaleas (id-number=1), a bunch of begonias (id-number=2) and a bunch of carnations (id-number=3). Now, all the bunches must be put into the vases keeping their id-numbers in order. The bunch of azaleas must be in a vase to the left of begonias, and the bunch of begonias must be in a vase to the left of carnations. If there are more vases than bunches of flowers then the excess will be left empty. A vase can hold only one bunch of flowers.

Each vase has a distinct characteristic (just like flowers do). Hence, putting a bunch of flowers in a vase results in a certain aesthetic value, expressed by an integer. The aesthetic values are presented in a table as shown below. Leaving a vase empty has an aesthetic value of 0.
 

V A S E S

1

2

3

4

5

Bunches

1 (azaleas)

7 23 -5 -24 16

2 (begonias)

5 21 -4 10 23

3 (carnations)

-21

5 -4 -20 20

According to the table, azaleas, for example, would look great in vase 2, but they would look awful in vase 4.

To achieve the most pleasant effect you have to maximize the sum of aesthetic values for the arrangement while keeping the required ordering of the flowers. If more than one arrangement has the maximal sum value, any one of them will be acceptable. You have to produce exactly one arrangement.

Input

  • The first line contains two numbers: F, V.
  • The following F lines: Each of these lines contains V integers, so that Aij is given as the jth number on the (i+1)st line of the input file.


  • 1 <= F <= 100 where F is the number of the bunches of flowers. The bunches are numbered 1 through F.
  • F <= V <= 100 where V is the number of vases.
  • -50 <= Aij <= 50 where Aij is the aesthetic value obtained by putting the flower bunch i into the vase j.

Output

The first line will contain the sum of aesthetic values for your arrangement.

Sample Input

3 5
7 23 -5 -24 16
5 21 -4 10 23
-21 5 -4 -20 20

Sample Output

53

Source

    因為題目中規定若i<j,則第i束花必須出現在第j束花之前,根據這一條件,可以用花的數目來進行動態規劃。設dp[i,j]為前i束花插在前j個花瓶中的最大美學值,有狀態轉移方程:dp[i,j]=max(dp[i-1,k-1]+A[i,k]),其中i<=k<=j,A[i,k]為第i束花插在第k個花瓶中的美學值,規定dp[i,0]=0,1<=i<=F。
#include<iostream>
using namespace std;

const int MAXN = 101;
const int inf = 10000;
int A[MAXN][MAXN],dp[MAXN][MAXN];

int main(){
    
int i,j,k,f,v,t;
    
while(scanf("%d %d",&f,&v)!=EOF){
        
for(i=1;i<=f;i++){
            dp[i][
0]=0;
            
for(j=1;j<=v;j++){
                scanf(
"%d",&A[i][j]);
                dp[i][j]
=-1;
            }

        }

        
for(i=1;i<=f;i++)
            
for(j=1;j<=v;j++)
                
for(t=-inf,k=i;k<=j;k++){
                    t
=max(t,dp[i-1][k-1]+A[i][k]);
                    
if(dp[i][j]==-1 || dp[i][j]<t)
                        dp[i][j]
=t;
                }

        printf(
"%d\n",dp[f][v]);
    }

    
return 0;
}

posted on 2009-06-16 13:57 極限定律 閱讀(1484) 評論(1)  編輯 收藏 引用 所屬分類: ACM/ICPC

評論

# re: POJ 1157 LITTLE SHOP OF FLOWERS 動態規劃 2009-11-17 21:57 Gamor

dp[i][j] = max(dp[i][j - 1], dp[i - 1][j - 1] + A[i][j])  回復  更多評論   

<2009年6月>
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

導航

統計

常用鏈接

留言簿(10)

隨筆分類

隨筆檔案

友情鏈接

搜索

最新評論

閱讀排行榜

評論排行榜

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            欧美一级午夜免费电影| 久久久天天操| 日韩天天综合| 欧美日韩精品免费观看视频完整| 91久久精品美女高潮| 亚洲成色www久久网站| 久久久久久夜精品精品免费| 欧美一区二区三区免费大片| 国产亚洲成人一区| 免费观看成人| 欧美激情91| 亚洲主播在线播放| 久久不射中文字幕| 亚洲欧洲日韩女同| 亚洲精品一区二区三区蜜桃久| 欧美人与性动交a欧美精品| 亚洲午夜av| 午夜精品久久久久久久久久久久久 | 亚洲高清一区二| 欧美精品在线观看播放| 亚洲影视在线| 久久久久成人精品| 夜夜狂射影院欧美极品| 亚洲在线观看视频网站| 在线播放精品| 日韩亚洲精品在线| 国模套图日韩精品一区二区| 亚洲国产精品国自产拍av秋霞| 欧美精品免费视频| 久久久久99| 欧美日韩在线观看视频| 快射av在线播放一区| 欧美激情一区二区三区高清视频 | 国产精品人人做人人爽人人添| 欧美中文字幕在线播放| 欧美1区2区| 久久午夜激情| 欧美午夜在线观看| 欧美高清视频在线观看| 国产精品毛片| 亚洲成人自拍视频| 国产亚洲精品激情久久| 日韩一级免费| 亚洲精品国产精品乱码不99| 午夜精品国产| 国产精品99久久久久久久vr| 久久久91精品国产一区二区精品| 亚洲夜晚福利在线观看| 免费在线成人av| 久久影院午夜论| 国产精品自拍在线| 日韩亚洲欧美成人| 99一区二区| 欧美精品啪啪| 欧美好骚综合网| 在线精品高清中文字幕| 欧美一区二区在线观看| 欧美中文日韩| 国产精品视频大全| 亚洲免费综合| 欧美在线播放| 国产精品一区二区三区成人| aa日韩免费精品视频一| 一本色道88久久加勒比精品| 免费一级欧美片在线观看| 玖玖综合伊人| 一区二区三区自拍| 久久久久99精品国产片| 久久亚洲欧美| 伊人久久综合97精品| 久久婷婷国产综合国色天香| 久热爱精品视频线路一| 悠悠资源网亚洲青| 久久亚洲视频| 欧美激情1区2区| 99国产精品视频免费观看| 欧美另类极品videosbest最新版本| 欧美韩国日本一区| 一本久道久久综合中文字幕| 欧美经典一区二区三区| 9色精品在线| 欧美在线一级va免费观看| 国产亚洲永久域名| 久久综合色播五月| 亚洲激情电影在线| 亚洲午夜免费福利视频| 国产精品视频福利| 久久狠狠一本精品综合网| 免费成人高清视频| 一区二区三区国产在线| 国产精品久久久久久久久免费樱桃 | 欧美高清在线视频| 99视频+国产日韩欧美| 国产精品99一区| 欧美在线视频二区| 亚洲国产精品一区二区www| 亚洲婷婷免费| 国产一区二区黄| 欧美肥婆在线| 亚洲午夜久久久久久久久电影网| 欧美一区二视频| 亚洲国产专区校园欧美| 欧美日产一区二区三区在线观看| 99精品视频一区| 久久久久久综合网天天| 99视频一区| 伊人久久成人| 国产精品久久久久影院亚瑟| 久久精品女人天堂| 中日韩美女免费视频网址在线观看| 久久女同互慰一区二区三区| 亚洲每日更新| 国模套图日韩精品一区二区| 欧美日韩国产小视频| 久久国产精品99久久久久久老狼| 亚洲电影一级黄| 久久精品视频在线| 亚洲一区二区三区高清| 狠狠色丁香婷婷综合| 国产精品男人爽免费视频1| 免费不卡欧美自拍视频| 欧美一区二区三区免费看| 亚洲精品少妇30p| 美女视频一区免费观看| 性欧美长视频| 亚洲一二三区视频在线观看| 亚洲欧洲一二三| 国产自产2019最新不卡| 国产精品实拍| 欧美日韩一卡| 欧美精品久久久久a| 欧美成人激情视频| 久久先锋资源| 久久久久久91香蕉国产| 午夜精品久久久久久99热软件| 99综合在线| 亚洲精品综合在线| 亚洲剧情一区二区| 亚洲久久一区| 99re6热在线精品视频播放速度| 欧美大片在线看| 欧美国产免费| 欧美高清视频免费观看| 欧美成人资源| 欧美国产精品日韩| 亚洲国产精品一区制服丝袜| 欧美成人高清| 亚洲二区在线观看| 亚洲国产天堂久久国产91| 亚洲高清自拍| 亚洲国产专区校园欧美| 亚洲精品乱码久久久久久久久| 亚洲国产精品悠悠久久琪琪| 亚洲欧洲精品一区二区三区| 亚洲激情在线| 99精品国产在热久久婷婷| 一本色道**综合亚洲精品蜜桃冫| 日韩一区二区久久| 亚洲午夜一区二区| 午夜久久福利| 牛牛国产精品| 欧美人在线视频| 国产精品伦一区| 激情综合五月天| 亚洲国产欧美日韩| 9国产精品视频| 亚洲一区制服诱惑| 欧美在线视频播放| 麻豆亚洲精品| 亚洲人午夜精品免费| 亚洲性视频h| 久久一区中文字幕| 欧美日韩国产不卡| 国产日韩欧美电影在线观看| 亚洲国产精品www| 亚洲午夜伦理| 美女任你摸久久| 亚洲三级免费电影| 午夜在线精品偷拍| 欧美1区2区| 国产日韩欧美自拍| 亚洲精品日韩在线观看| 午夜精品久久久久久99热| 久久一区二区三区国产精品| 亚洲人成人一区二区三区| 亚洲欧美日韩综合一区| 欧美成黄导航| 国产无一区二区| 一区二区三区日韩| 免费在线观看成人av| 一区二区成人精品| 久久网站热最新地址| 国产精品日韩专区| 亚洲伦理中文字幕| 久久伊人免费视频| 午夜精品免费| 国产精品va| 日韩小视频在线观看专区| 久久综合伊人77777| 这里只有精品视频在线|