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

            我希望你是我獨(dú)家記憶

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

            USACO——423——逆序貪心

            Posted on 2008-08-05 16:33 Hero 閱讀(135) 評論(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] ;//機(jī)器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).

            久久精品视频91| 久久久久精品国产亚洲AV无码| 精品熟女少妇AV免费久久| 久久成人永久免费播放| 久久精品国产影库免费看| 久久婷婷五月综合色高清| 久久AV无码精品人妻糸列| 亚洲欧美一区二区三区久久| 久久精品国产亚洲Aⅴ蜜臀色欲| 久久se精品一区精品二区| 久久国产精品99久久久久久老狼| 久久久久亚洲精品天堂| 久久亚洲国产成人精品性色| 久久久精品2019免费观看| 97久久超碰国产精品旧版| 国产精品一久久香蕉国产线看| 国产精品久久久久影视不卡| 精品午夜久久福利大片| 久久综合九色综合欧美狠狠| 国产成人精品久久亚洲| 久久久中文字幕日本| 精品久久久久久无码不卡| 国产精品久久婷婷六月丁香| 亚洲va国产va天堂va久久| 久久99精品久久久久久动态图 | 久久精品无码一区二区三区日韩| 国产激情久久久久影院| 欧美色综合久久久久久| 99久久夜色精品国产网站| 97久久国产亚洲精品超碰热 | 久久精品国产日本波多野结衣| 国产精品99久久久精品无码| 久久亚洲AV成人无码电影| 久久综合狠狠综合久久激情 | 久久九色综合九色99伊人| 久久精品国产久精国产一老狼| av国内精品久久久久影院| 久久久久久亚洲精品不卡 | 久久久噜噜噜久久中文字幕色伊伊 | 国产农村妇女毛片精品久久| 亚洲精品午夜国产va久久|