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

            我希望你是我獨家記憶

            一段永遠封存的記憶,隨風而去
            posts - 263, comments - 31, trackbacks - 0, articles - 3
               :: 首頁 :: 新隨筆 ::  :: 聚合  :: 管理

            USACO——423——逆序貪心

            Posted on 2008-08-05 16:33 Hero 閱讀(138) 評論(0)  編輯 收藏 引用 所屬分類: 代碼如詩--ACM
            /*
            ID: wangzha4
            LANG: C++
            TASK: job
            */
            #include 
            <stdio.h>
            #include 
            <stdlib.h>
            #include 
            <string.h>
            #include 
            <ctype.h>
            #define llong unsigned long long 
            #define unint unsigned int
            #define printline  printf( "\n" ) 

            double fmax( double a, double b )
            {
                
            if( a - b > 0 )    return a ;
                
            else            return b ;
            }

            double fmin( double a, double b )
            {
                
            if( a - b < 0 )    return a ;
                
            else            return b ;
            }

            int fmax( int a, int b )
            {
                
            if( a > b )    return a ;
                
            else        return b ;
            }

            int fmin( int a, int b )
            {
                
            if( a < b )    return a ;
                
            else        return b ;
            }

            int fpow( int a, int b )
            {
                
            int reval = 1 ;
                
            forint i=1; i<=b; i++ )
                    reval 
            *= a ;
                
            return reval ;
            }
            const int INF = 1000000 ;
            const int size = 155 ;

            int ina, inb, inn ;

            int A[40], B[40] ;
            int finishA[1100], finishB[1100] ;
            int restartA[40], restartB[40] ;//機器A和B重新啟動的時間

            void input()
            {
                scanf( 
            "%d %d %d"&inn, &ina, &inb ) ;
                
            forint i=1; i<=ina; i++ ) {
                    scanf( 
            "%d"&A[i] ) ; restartA[i] = 0 ;
                }
                
                
            forint i=1; i<=inb; i++ ) {
                    scanf( 
            "%d"&B[i] ) ; restartB[i] = 0 ;
                }
            }

            void work()
            {
                
            int minval = INF ; int minnum = -1 ;
                
            forint i=1; i<=inn; i++ ) {
                    
                    minval 
            = INF ; minnum = -1 ;
                    
            forint j=1; j<=ina; j++ ) {
                        
            if( minval > restartA[j] + A[j] ) {
                            minval 
            = restartA[j] + A[j] ; minnum = j ;
                        }
                    }
                    restartA[minnum] 
            = minval ; finishA[i] = minval ;
                    
                    minval 
            = INF ; minnum = -1 ;
                    
            forint j=1; j<=inb; j++ ) {
                        
            if( minval > restartB[j] + B[j] ) {
                            minval 
            = restartB[j] + B[j] ; minnum = j ;
                        }
                    }
                    restartB[minnum] 
            = minval ; finishB[i] = minval ;
                }
                
                printf( 
            "%d ", finishA[inn] ) ;
                
                
            int maxval = -1 ;
                
            forint i=1; i<=inn; i++ ) {
                    
            if( maxval < finishA[i] + finishB[inn+1-i] )
                        maxval 
            = finishA[i] + finishB[inn+1-i] ;
                }
                
                printf( 
            "%d\n", maxval ) ;
            }

            int main()
            {
                freopen( 
            "job.in""r", stdin ) ;
                freopen( 
            "job.out","w",stdout ) ;

                input() ;
                
            //init() ;
                work() ;
                
                
            return 0 ;
            }


            Once these two calculations have been done and the arrays have been sorted, you end up with a picture like this:


            Each line represents the activity of one job. Green and blue are "A" machines, and yellow, cyan, and purple are type "B" machines. A red line means that the job is in a container instead of a machine. The left portion corresponds to "A" jobs, where the end of each line is the time at which the kth job is completed. The right portion corresponds to "B" jobs, where the beginning of the line is the earliest that the kth job can be started with respect to the ending time of the all the "B" jobs. The white space in the middle represents the `slack' time, the time that the job sits in an intermediate container.

            The best option is to match up the earliest completed "A" job with the "B" job that starts earliest, the second earliest completed "A" job with the second earliest started "B" job, etc. Take the maximum of these times. This corresponds to moving the the two representations together until they touch (one job has no 'slack' time).

            色诱久久久久综合网ywww| 国产午夜精品理论片久久影视| 国产成人精品久久免费动漫| 久久99国产精品尤物| 九九99精品久久久久久| 国产精品欧美亚洲韩国日本久久| 久久996热精品xxxx| 色老头网站久久网| 久久午夜无码鲁丝片| 激情五月综合综合久久69| 久久久久久精品无码人妻| 久久福利青草精品资源站免费| 日韩美女18网站久久精品| 久久久无码精品亚洲日韩按摩 | 青青久久精品国产免费看| 久久婷婷国产剧情内射白浆| 精品久久香蕉国产线看观看亚洲| 久久精品国产亚洲一区二区三区 | 久久精品夜色噜噜亚洲A∨| 精产国品久久一二三产区区别| 久久精品国产91久久麻豆自制| 日韩美女18网站久久精品| 国产精品久久自在自线观看| 久久人人爽人人爽人人片AV不 | 久久国产精品久久精品国产| 中文字幕久久亚洲一区| 久久国产精品久久久| 人妻少妇久久中文字幕| 色青青草原桃花久久综合| 999久久久国产精品| 99精品国产在热久久无毒不卡| 久久久久久久波多野结衣高潮| 日产久久强奸免费的看| 久久久久亚洲AV成人网人人软件| 久久99热狠狠色精品一区| 国内精品久久久久久99蜜桃| 久久久久久曰本AV免费免费| 一本大道久久东京热无码AV| 亚洲伊人久久成综合人影院 | 伊人久久精品无码二区麻豆| 久久久亚洲精品蜜桃臀|