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

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本書(編號為12,M),想將每本復制一份,M本書的頁數可能不同(分別是P1,P2PM)。任務時將這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 極限定律 閱讀(3694) 評論(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年7月>
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

導航

統計

常用鏈接

留言簿(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>
            亚洲精品国产欧美| 亚洲欧美日韩成人| 免费成人av资源网| 在线日韩欧美| 欧美黑人在线播放| 欧美精品日韩三级| 亚洲伊人一本大道中文字幕| 中文一区二区| 韩国欧美一区| 亚洲欧洲中文日韩久久av乱码| 欧美激情一区在线| 亚洲欧美福利一区二区| 欧美影院在线| 亚洲精品自在久久| 国产精品99久久99久久久二8| 国产模特精品视频久久久久 | 美女露胸一区二区三区| 亚洲欧洲一二三| 99这里有精品| 国内成人自拍视频| 91久久精品国产91久久性色tv| 欧美亚洲第一页| 玖玖视频精品| 欧美日韩一区在线观看| 欧美制服丝袜| 欧美绝品在线观看成人午夜影视 | 亚洲黄色三级| 一区二区三区久久精品| 在线精品在线| 亚洲免费在线观看| 亚洲国产女人aaa毛片在线| 亚洲一区二区三区高清| 国内偷自视频区视频综合| 毛片基地黄久久久久久天堂| 欧美成人免费全部| 久久精品1区| 欧美日韩成人网| 男男成人高潮片免费网站| 国产精品国产精品| 亚洲狠狠婷婷| 一区二区三区无毛| 亚洲女女女同性video| 一区二区国产精品| 久久一区亚洲| 老司机精品视频网站| 国产精品久久久久9999高清| 亚洲福利一区| 亚洲国产小视频在线观看| 午夜精品久久久久影视| 亚洲天堂网在线观看| 欧美高清一区二区| 免费亚洲一区| 影音欧美亚洲| 久久久久久久网| 久久婷婷国产麻豆91天堂| 国产精品你懂的| 一区二区三区精品国产| 中文国产一区| 欧美日韩精品系列| 日韩午夜三级在线| 一本色道久久综合亚洲二区三区| 噜噜噜91成人网| 欧美丰满高潮xxxx喷水动漫| 加勒比av一区二区| 久久久91精品国产| 久久综合久久综合九色| 黄色成人在线观看| 久久精品国产91精品亚洲| 久久综合免费视频影院| 在线观看三级视频欧美| 久久久亚洲一区| 亚洲第一精品电影| 亚洲精品乱码久久久久久久久| 美女精品自拍一二三四| 亚洲国产精品久久久久婷婷884 | 欧美不卡激情三级在线观看| 欧美成人情趣视频| 亚洲精品国产无天堂网2021| 欧美国产日韩a欧美在线观看| 亚洲第一区在线| 一本色道久久综合亚洲精品按摩| 欧美日韩国产在线看| 亚洲一区二区av电影| 欧美中文字幕在线视频| 精品51国产黑色丝袜高跟鞋| 噜噜噜噜噜久久久久久91 | 午夜在线视频观看日韩17c| 国产亚洲第一区| 噜噜噜躁狠狠躁狠狠精品视频| 欧美激情亚洲激情| 亚洲一级黄色| 韩国精品一区二区三区| 欧美交受高潮1| 亚洲欧美国产日韩天堂区| 久久视频在线视频| 99热精品在线观看| 国产免费观看久久黄| 免费亚洲网站| 亚洲一区日韩在线| 免费在线看一区| 午夜精品福利在线| 亚洲国产成人久久综合| 欧美日韩综合在线| 久久中文字幕一区| 亚洲一区二区三区视频播放| 久热精品视频在线观看| 亚洲一卡二卡三卡四卡五卡| 在线不卡亚洲| 欧美性色综合| 免费观看久久久4p| 欧美亚洲专区| 一区二区av在线| 免播放器亚洲一区| 午夜精品久久99蜜桃的功能介绍| 亚洲高清视频在线观看| 国产乱码精品| 欧美日韩精品在线视频| 久久性天堂网| 欧美一区二视频| 亚洲伊人第一页| 亚洲精品裸体| 亚洲成色777777在线观看影院| 午夜精彩国产免费不卡不顿大片| 亚洲精品欧洲| 亚洲黄色成人久久久| 国内精品久久久久久 | 在线不卡欧美| 国产无遮挡一区二区三区毛片日本| 欧美激情精品久久久六区热门| 久久精品国产99国产精品| 亚洲免费综合| 亚洲网址在线| 亚洲一区www| 在线亚洲激情| 中文国产一区| 一区二区三区色| 99热这里只有成人精品国产| 亚洲三级视频| 亚洲日韩视频| 日韩视频免费在线| 亚洲精品美女在线观看| 亚洲黄色av一区| 亚洲国产成人av| 亚洲精品乱码久久久久久蜜桃麻豆 | 欧美一区成人| 欧美一区二区视频观看视频| 亚洲女ⅴideoshd黑人| 亚洲一二区在线| 午夜精品视频在线| 久久精品国产99| 久久精品成人欧美大片古装| 久久精品国产精品亚洲综合| 久久精品国产清高在天天线| 久久精品青青大伊人av| 久久综合九色欧美综合狠狠| 久热成人在线视频| 亚洲国产精品视频| 亚洲三级影院| 在线视频日韩| 久久国产加勒比精品无码| 久久久久久久综合狠狠综合| 欧美成人资源| 国产精品久久久久av| 国产婷婷精品| 亚洲精品国产拍免费91在线| 在线视频欧美精品| 香蕉久久国产| 欧美va亚洲va香蕉在线| 日韩视频免费观看| 小辣椒精品导航| 欧美成人精品| 国产精品一卡二| 亚洲国产影院| 亚洲欧美日本国产专区一区| 久久久久久久一区二区三区| 亚洲成人在线视频播放| 欧美激情亚洲自拍| 一区二区三区日韩欧美| 久久久精品一区| 欧美三级精品| 亚洲大片免费看| 午夜精品福利在线| 亚洲国产精品久久久久久女王| 夜夜爽夜夜爽精品视频| 久久xxxx精品视频| 欧美日韩中文字幕| 在线观看国产成人av片| 亚洲欧美日韩国产综合精品二区| 久久乐国产精品| 中日韩美女免费视频网站在线观看| 久久精品国产一区二区三区| 欧美日韩亚洲综合| 亚洲国产精品激情在线观看| 亚洲伊人第一页| 亚洲黄色片网站| 久久高清免费观看| 国产精品中文字幕欧美| 亚洲精品欧洲精品| 久久影院午夜论| 午夜欧美精品|