• <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 閱讀(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] ;//機器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).

            免费久久人人爽人人爽av| 国产一区二区三精品久久久无广告| 久久精品一区二区三区中文字幕| 久久精品三级视频| 久久婷婷五月综合97色| 久久国产精品久久国产精品| 国产成人久久精品二区三区| 久久人妻AV中文字幕| 国产产无码乱码精品久久鸭| 久久99精品久久久久久不卡| 久久久久久久久波多野高潮| 久久久青草青青亚洲国产免观| 久久se精品一区二区影院 | 久久久久久亚洲精品不卡 | 狠狠色噜噜色狠狠狠综合久久 | 亚洲AV无码久久精品成人 | 精品久久久久久亚洲精品| 久久久久香蕉视频| 久久国产精品-国产精品| 久久亚洲日韩看片无码| Xx性欧美肥妇精品久久久久久| 婷婷久久久亚洲欧洲日产国码AV| 国产成人精品久久亚洲高清不卡 国产成人精品久久亚洲高清不卡 国产成人精品久久亚洲 | 精品伊人久久大线蕉色首页| 国产呻吟久久久久久久92| 久久久久99精品成人片试看| 亚洲AⅤ优女AV综合久久久| 91久久精品无码一区二区毛片| 亚洲欧美日韩久久精品第一区| 国产精品综合久久第一页| 国内精品久久久久| 久久久久久久尹人综合网亚洲| 久久久久免费看成人影片| AV无码久久久久不卡蜜桃| 亚洲精品NV久久久久久久久久 | 国产精品内射久久久久欢欢| 久久99精品国产99久久6男男| 久久精品国产亚洲av水果派| 无码人妻久久一区二区三区免费丨| 久久久久久久综合狠狠综合| 久久人人爽人人澡人人高潮AV|