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

POJ 1505 Copying Books 動態規劃

Description

Before the invention of book-printing, it was very hard to make a copy of a book. All the contents had to be re-written by hand by so called scribers. The scriber had been given a book and after several months he finished its copy. One of the most famous scribers lived in the 15th century and his name was Xaverius Endricus Remius Ontius Xendrianus (Xerox). Anyway, the work was very annoying and boring. And the only way to speed it up was to hire more scribers.

Once upon a time, there was a theater ensemble that wanted to play famous Antique Tragedies. The scripts of these plays were divided into many books and actors needed more copies of them, of course. So they hired many scribers to make copies of these books. Imagine you have m books (numbered 1, 2 ... m) that may have different number of pages (p1, p2 ... pm) and you want to make one copy of each of them. Your task is to divide these books among k scribes, k <= m. Each book can be assigned to a single scriber only, and every scriber must get a continuous sequence of books. That means, there exists an increasing succession of numbers 0 = b0 < b1 < b2, ... < bk-1 <= bk = m such that i-th scriber gets a sequence of books with numbers between bi-1+1 and bi. The time needed to make a copy of all the books is determined by the scriber who was assigned the most work. Therefore, our goal is to minimize the maximum number of pages assigned to a single scriber. Your task is to find the optimal assignment.

Input

The input consists of N cases. The first line of the input contains only positive integer N. Then follow the cases. Each case consists of exactly two lines. At the first line, there are two integers m and k, 1 <= k <= m <= 500. At the second line, there are integers p1, p2, ... pm separated by spaces. All these values are positive and less than 10000000.

Output

For each case, print exactly one line. The line must contain the input succession p1, p2, ... pm divided into exactly k parts such that the maximum sum of a single part should be as small as possible. Use the slash character ('/') to separate the parts. There must be exactly one space character between any two successive numbers and between the number and the slash.

If there is more than one solution, print the one that minimizes the work assigned to the first scriber, then to the second scriber etc. But each scriber must be assigned at least one book.

Sample Input

2
9 3
100 200 300 400 500 600 700 800 900
5 4
100 100 100 100 100

Sample Output

100 200 300 400 500 / 600 700 / 800 900
100 / 100 / 100 / 100 100

Source

     

    假設有M本書(編號為12M),想將每本復制一份,M本書的頁數可能不同(分別是P1P2PM)。任務時將這M本書分給K個抄寫員(KM〉,每本書只能分配給一個抄寫員進行復制,而每個抄寫員所分配到的書必須是連續順序的。

    意思是說,存在一個連續升序數列0=b0b1b2bk-1bk=m,這樣,第i號抄寫員得到的書稿是從bi-1+1到第bi本書。復制工作是同時開始進行的,并且每個抄寫員復制的速度都是一樣的。所以,復制完所有書稿所需時間取決于分配得到最多工作的那個抄寫員的復制時間。試找一個最優分配方案,使分配給每一個抄寫員的頁數的最大值盡可能小(如存在多個最優方案,只輸出其中一種)。
    設dp[i,j]表示前j個人復制前i本書所需要的最少時間,有狀態轉移方程dp[i,j]=min(dp[i,j],max(dp[v,j-1],sum[v+1,i])),其中1<=i<=m,1<=j<=k,j-1<=v<=i-1,sum[v+1,j]表示第v+1本書到第i本書的頁數之和。

#include<iostream>
using namespace std;

const int MAXN = 510;
int sum[MAXN],path[MAXN],dp[MAXN][MAXN];

int main(){
    
int m,k,i,j,v,ca,p,t;
    scanf(
"%d",&ca);
    
while(ca--){
        scanf(
"%d %d",&m,&k);
        
for(sum[0]=0,i=1;i<=m;i++){
            scanf(
"%d",&p);
            sum[i]
=sum[i-1]+p;
        }

        memset(dp,
-1,sizeof(dp));
        
for(dp[0][0]=0,i=1;i<=m;i++)
            
for(j=1;j<=&& j<=k;j++){
                
if(j==1) dp[i][j]=sum[i];
                
else
                    
for(v=j-1;v<=i-1;v++){
                        t
=max(dp[v][j-1],sum[i]-sum[v]);
                        
if(dp[i][j]==-1 || t<=dp[i][j]) 
                            dp[i][j]
=t;
                    }

            }

        
for(i=m,j=k-1,p=0;i>=1;i--){
            p
+=sum[i]-sum[i-1];
            
if(p>dp[m][k] || i<=j){
                path[j
--]=i+1;
                p
=sum[i]-sum[i-1];
            }

        }

        
for(i=j=1;i<=m;i++){
            
if(i>1) printf(" ");
            
if(j<&& path[j]==i){
                printf(
"");
                j
++;
            }

            printf(
"%d",sum[i]-sum[i-1]);
        }

        printf(
"\n");
    }

    
return 0;
}

posted on 2009-06-16 09:59 極限定律 閱讀(3629) 評論(12)  編輯 收藏 引用 所屬分類: ACM/ICPC

評論

# re: POJ 1505 Copying Books 動態規劃 2009-06-16 22:30 bafangprinter

China-Beijing bafang printing plant,Offers business printing services ,Full colour printing service for brochures,paper bag,newsletters,magazines,catalogues,Boxprinting,Paper processing,Drugs ,Business Cards, Box,Jewel box,Gift box,Kraft paper bags,Corrugated Box,Beijing Printing, Foreigners in China ,All are welcome to the Advisory order! TEL:86-010-51665543 MSN:beijingbafang@hotmail.com http://www.print861.com Fengtai District Beijing  China   回復  更多評論   

# re: POJ 1505 Copying Books 動態規劃 2009-11-17 22:21 Gamor

二分最大值也可以過。  回復  更多評論   

# re: POJ 1505 Copying Books 動態規劃 2010-07-18 19:33 AnnetteKRAMER

I would like to propose not to hold back until you get enough amount of cash to buy different goods! You can just get the <a href="http://bestfinance-blog.com/topics/personal-loans">personal loans</a> or just secured loan and feel yourself comfortable   回復  更多評論   

# re: POJ 1505 Copying Books 動態規劃 2010-08-02 17:01 buy essay

Study process demands creative writing skills, nevertheless, college students, which don't have time can fail their academic career. Hence, to purchase the term papers from the buy term paper service would be a right decision.   回復  更多評論   

# re: POJ 1505 Copying Books 動態規劃 2010-08-05 16:36 term paper

This is what I was exploring for a long time! Thanks for this article around university! One time somebody state that In union there is effect. Our powerfully skilled service can help you in writing custom research papers.  回復  更多評論   

# re: POJ 1505 Copying Books 動態規劃 2010-08-11 20:30 essay writing service

Do you work a lot on your writing assignment? You do not have to bother about that any longer, because you can buy essay papers.   回復  更多評論   

# re: POJ 1505 Copying Books 動態規劃[未登錄] 2010-09-25 11:15 dress

Best canon Coffee Mugs! Funny, Cute, & Humorous Unique designs. Also find Travel Mugs, Coffee Cups also, or Create Photo Personalized Mugs & Drinkware  回復  更多評論   

# re: POJ 1505 Copying Books 動態規劃 2012-02-11 12:45 resume writing

The article you post by scribers is very interesting, now we understand how xerox copy machine came to being, its a great info.  回復  更多評論   

# re: POJ 1505 Copying Books 動態規劃 2012-04-17 16:09 help in writing term papers

This article defines how things came to being,here i found so many information related to copying books and machines.Its nice to read this book.  回復  更多評論   

# re: POJ 1505 Copying Books 動態規劃[未登錄] 2013-05-12 19:40 BETTY

格式有點囧  回復  更多評論   

# re: POJ 1505 Copying Books 動態規劃 2013-06-17 20:01 this site

Go to Perfect-resume company (perfect-resume.com) if you are in need of reliable resume services. Having delt with this trustable agency, you will be aware of which service to choose for buying resume and where to look through samples of resume writing. Don’t mull over, buy CV of good quality from expert resume writers.  回復  更多評論   

# re: POJ 1505 Copying Books 動態規劃 2013-06-17 20:02 Internet site

Professional resume writers review will hint you where to buy resume paper if you are too busy to write a resume, just visit Resumes expert company resumesexpert.com, view resume writing samples and our certified resume writers will be ready to provide you best CV writing. Buying resume with us is pretty easy, buy resumes now and stay satisfied about your career.  回復  更多評論   

<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久久精品国产91久久性色tv| 亚洲韩国日本中文字幕| 欧美特黄一级| 免费视频最近日韩| 亚洲欧美激情诱惑| 91久久精品美女| 久久夜色撩人精品| 欧美一区二区三区视频免费| 亚洲国产综合在线| 国内精品一区二区三区| 欧美日韩中文字幕精品| 欧美国产乱视频| 久久久噜噜噜久久久| 香蕉久久a毛片| 亚洲欧美日韩国产| 91久久综合亚洲鲁鲁五月天| 欧美一区二区三区在线看| 亚洲一区二区精品在线观看| 一区二区三区**美女毛片| 激情久久影院| 国产在线视频欧美| 亚洲电影第1页| 亚洲欧洲日产国产网站| 亚洲国产另类 国产精品国产免费| 国产精品日韩精品欧美在线| 国产精品久久久久免费a∨| 欧美日韩色综合| 欧美日韩免费视频| 欧美另类一区| 国产欧美亚洲视频| 在线国产欧美| 亚洲一级片在线观看| 久久精品夜色噜噜亚洲a∨| 欧美国产视频一区二区| 在线天堂一区av电影| 久久精品中文字幕一区二区三区| 久久在线视频在线| 欧美午夜美女看片| 国产自产女人91一区在线观看| 在线欧美日韩| 欧美一区二区三区久久精品| 美女露胸一区二区三区| 亚洲无线视频| 欧美日韩国产123| 国产一区二区三区四区老人| 一区二区三区欧美在线观看| 久久夜色精品国产噜噜av| 99亚洲一区二区| 欧美韩日亚洲| 在线精品视频一区二区| 亚洲在线观看免费视频| 亚洲欧洲另类国产综合| 麻豆成人精品| 黄色一区二区在线观看| 欧美在线视频免费观看| 亚洲精品美女在线观看| 久久久久国产精品麻豆ai换脸| 欧美日韩视频| 亚洲一级在线观看| 亚洲区免费影片| 欧美久久综合| 亚洲自拍16p| 午夜精品美女自拍福到在线 | 欧美母乳在线| 亚洲精品美女久久久久| 亚洲高清一区二| 欧美精品日韩三级| 一区二区三区 在线观看视频| 亚洲美女网站| 国产午夜精品美女视频明星a级| 亚洲综合色自拍一区| 午夜精品一区二区三区电影天堂| 国产精品五月天| 开心色5月久久精品| 免费亚洲电影在线观看| 一区二区高清视频| 欧美亚洲日本网站| 亚洲免费精彩视频| 亚洲综合电影| 亚洲电影观看| 亚洲男女自偷自拍| 最新国产の精品合集bt伙计| 亚洲另类视频| 亚洲第一视频| 久久高清福利视频| av成人天堂| 久久久久一区二区三区| 亚洲欧美国产日韩中文字幕| 久久久av水蜜桃| 亚洲小视频在线观看| 久久亚洲国产成人| 久久免费99精品久久久久久| 欧美三级视频在线播放| 久久亚洲图片| 国产综合色在线| 性一交一乱一区二区洋洋av| 亚洲深夜av| 欧美午夜片在线免费观看| 亚洲二区在线观看| 亚洲国产精品一区二区www| 久久精品99国产精品| 久久不射电影网| 国产精品亚洲一区| 亚洲免费一在线| 欧美一区二区福利在线| 久久综合九色综合欧美就去吻| 国产精品手机在线| 亚洲欧美国产三级| 欧美在线日韩在线| 国产亚洲成人一区| 久久久久久久999精品视频| 久久精品一区二区三区不卡牛牛| 国产精品美女久久福利网站| 亚洲一区日韩在线| 久久精品国产精品亚洲精品| 激情欧美亚洲| 欧美精品成人在线| 中文av字幕一区| 久久久91精品国产一区二区三区 | 影音先锋亚洲精品| 免费视频一区| 亚洲深夜影院| 欧美jizzhd精品欧美喷水| 亚洲一区二区三区高清不卡| 国产精品尤物| 欧美91精品| 欧美影院精品一区| 亚洲精品久久7777| 麻豆av一区二区三区| 亚洲一区二区三区四区五区午夜| 国产亚洲网站| 国产精品私房写真福利视频| 欧美日韩一二三四五区| 久久免费精品日本久久中文字幕| 欧美在线国产精品| 亚洲免费视频中文字幕| 中文一区二区| 亚洲人成网站色ww在线| 久久国产精品亚洲va麻豆| 亚洲看片网站| 亚洲一区二区在| 卡通动漫国产精品| 亚洲欧洲日本国产| 免费在线日韩av| 亚洲人成绝费网站色www| 亚洲视频一二区| 亚洲欧美成人网| 国产女人18毛片水18精品| 亚洲一区二区毛片| 亚洲一级网站| 久久久久一区二区| 欧美亚洲免费电影| 国产精品任我爽爆在线播放| 亚洲一区二区动漫| 麻豆精品91| 欧美成人官网二区| 亚洲精品欧美在线| 激情久久久久久久| 国产精品少妇自拍| 久久三级视频| 欧美成人综合一区| 久久久久久久一区二区| 欧美在线观看视频一区二区| 国产亚洲亚洲| 欧美一区二区三区日韩| 亚洲第一毛片| 久久久999成人| 久久综合久久综合久久| 国产欧美日韩不卡| 欧美偷拍另类| 国内久久精品视频| 亚洲欧美精品在线观看| 亚洲欧美在线磁力| 亚洲综合色丁香婷婷六月图片| 欧美中文在线免费| 亚洲激情图片小说视频| 亚洲一区二区三区乱码aⅴ蜜桃女 亚洲一区二区三区乱码aⅴ | 欧美二区不卡| 久久久水蜜桃av免费网站| 亚洲国产清纯| 午夜精品久久久| 亚洲国产高清高潮精品美女| 蜜臀av性久久久久蜜臀aⅴ| 欧美a级理论片| 蜜桃av一区二区三区| 国产精品日本一区二区| 能在线观看的日韩av| 欧美一区二区视频在线| 亚洲视频免费观看| 亚洲一区综合| 亚洲观看高清完整版在线观看| 国产欧美日韩专区发布| 一本色道婷婷久久欧美| 亚洲欧美日韩网| 亚洲国产精品悠悠久久琪琪| 欧美在线观看视频在线 | 欧美黑人一区二区三区| 欧美激情一区二区三级高清视频 |