• <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>

            POJ 1505 Copying Books 動(dòng)態(tài)規(guī)劃

            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

                 

                假設(shè)有M本書(shū)(編號(hào)為12M),想將每本復(fù)制一份,M本書(shū)的頁(yè)數(shù)可能不同(分別是P1P2PM)。任務(wù)時(shí)將這M本書(shū)分給K個(gè)抄寫(xiě)員(KM〉,每本書(shū)只能分配給一個(gè)抄寫(xiě)員進(jìn)行復(fù)制,而每個(gè)抄寫(xiě)員所分配到的書(shū)必須是連續(xù)順序的。

                意思是說(shuō),存在一個(gè)連續(xù)升序數(shù)列0=b0b1b2bk-1bk=m,這樣,第i號(hào)抄寫(xiě)員得到的書(shū)稿是從bi-1+1到第bi本書(shū)。復(fù)制工作是同時(shí)開(kāi)始進(jìn)行的,并且每個(gè)抄寫(xiě)員復(fù)制的速度都是一樣的。所以,復(fù)制完所有書(shū)稿所需時(shí)間取決于分配得到最多工作的那個(gè)抄寫(xiě)員的復(fù)制時(shí)間。試找一個(gè)最優(yōu)分配方案,使分配給每一個(gè)抄寫(xiě)員的頁(yè)數(shù)的最大值盡可能小(如存在多個(gè)最優(yōu)方案,只輸出其中一種)。
                設(shè)dp[i,j]表示前j個(gè)人復(fù)制前i本書(shū)所需要的最少時(shí)間,有狀態(tài)轉(zhuǎn)移方程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本書(shū)到第i本書(shū)的頁(yè)數(shù)之和。

            #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 極限定律 閱讀(3576) 評(píng)論(12)  編輯 收藏 引用 所屬分類(lèi): ACM/ICPC

            評(píng)論

            # re: POJ 1505 Copying Books 動(dòng)態(tài)規(guī)劃 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   回復(fù)  更多評(píng)論   

            # re: POJ 1505 Copying Books 動(dòng)態(tài)規(guī)劃 2009-11-17 22:21 Gamor

            二分最大值也可以過(guò)。  回復(fù)  更多評(píng)論   

            # re: POJ 1505 Copying Books 動(dòng)態(tài)規(guī)劃 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   回復(fù)  更多評(píng)論   

            # re: POJ 1505 Copying Books 動(dòng)態(tài)規(guī)劃 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.   回復(fù)  更多評(píng)論   

            # re: POJ 1505 Copying Books 動(dòng)態(tài)規(guī)劃 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.  回復(fù)  更多評(píng)論   

            # re: POJ 1505 Copying Books 動(dòng)態(tài)規(guī)劃 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.   回復(fù)  更多評(píng)論   

            # re: POJ 1505 Copying Books 動(dòng)態(tài)規(guī)劃[未登錄](méi) 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  回復(fù)  更多評(píng)論   

            # re: POJ 1505 Copying Books 動(dòng)態(tài)規(guī)劃 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.  回復(fù)  更多評(píng)論   

            # re: POJ 1505 Copying Books 動(dòng)態(tài)規(guī)劃 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.  回復(fù)  更多評(píng)論   

            # re: POJ 1505 Copying Books 動(dòng)態(tài)規(guī)劃[未登錄](méi) 2013-05-12 19:40 BETTY

            格式有點(diǎn)囧  回復(fù)  更多評(píng)論   

            # re: POJ 1505 Copying Books 動(dòng)態(tài)規(guī)劃 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.  回復(fù)  更多評(píng)論   

            # re: POJ 1505 Copying Books 動(dòng)態(tài)規(guī)劃 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.  回復(fù)  更多評(píng)論   

            <2025年6月>
            25262728293031
            1234567
            891011121314
            15161718192021
            22232425262728
            293012345

            導(dǎo)航

            統(tǒng)計(jì)

            常用鏈接

            留言簿(10)

            隨筆分類(lèi)

            隨筆檔案

            友情鏈接

            搜索

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            少妇内射兰兰久久| 久久久国产精华液| 亚洲国产另类久久久精品小说 | 久久综合九色综合网站| 久久99国产综合精品| 精品久久久久久国产三级| 久久人人爽人人爽人人片AV东京热 | 久久大香萑太香蕉av| 精品少妇人妻av无码久久| 国产精品成人精品久久久 | 久久这里的只有是精品23| 久久精品亚洲中文字幕无码麻豆| 国产三级精品久久| 国内精品伊人久久久久AV影院| 激情五月综合综合久久69| 亚洲欧洲日产国码无码久久99 | 7777久久久国产精品消防器材| 国产精品99久久精品| 亚洲欧美日韩精品久久亚洲区 | 怡红院日本一道日本久久 | 国产女人aaa级久久久级| 久久亚洲精品无码aⅴ大香| 久久亚洲精品视频| 久久99热只有频精品8| 久久香综合精品久久伊人| 精品久久久无码中文字幕| 99久久免费国产特黄| 天天爽天天狠久久久综合麻豆| 久久久www免费人成精品| 久久亚洲中文字幕精品一区| 国产福利电影一区二区三区久久久久成人精品综合 | 亚洲精品国产第一综合99久久| 国产成人精品综合久久久| 久久香蕉一级毛片| 99久久精品国产一区二区| 久久久精品免费国产四虎| 久久国产精品-久久精品| 99久久精品费精品国产一区二区 | 亚洲AV无码久久| 性欧美大战久久久久久久久| 中文字幕无码免费久久|