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

            久久精品国产亚洲77777| 亚洲乱码日产精品a级毛片久久 | 好久久免费视频高清| 无码精品久久久天天影视| 精品熟女少妇AV免费久久| 欧美日韩精品久久久久| 久久久久人妻一区精品| 综合久久给合久久狠狠狠97色 | 久久精品国产秦先生| 久久九九青青国产精品| 日韩欧美亚洲综合久久影院d3| 久久精品国产一区| 亚洲国产日韩综合久久精品| 久久青青草原精品国产不卡| 国产精品成人久久久久三级午夜电影 | 午夜欧美精品久久久久久久| 99久久国产亚洲综合精品| 香蕉久久夜色精品升级完成| 亚洲综合熟女久久久30p| 久久国产精品77777| 久久不见久久见免费影院www日本| 久久免费香蕉视频| 欧美久久综合性欧美| 久久久亚洲裙底偷窥综合| 亚洲欧美日韩久久精品第一区| 欧美一区二区精品久久| 久久久久久久久久久精品尤物| 91精品国产91久久综合| 久久无码一区二区三区少妇| 性做久久久久久久久| 久久99久国产麻精品66 | 久久精品国产精品亚洲下载| 久久国产三级无码一区二区| 久久伊人色| 久久免费99精品国产自在现线| 久久国产精品国产自线拍免费| 午夜福利91久久福利| 大美女久久久久久j久久| 欧洲成人午夜精品无码区久久| 国产成人久久精品麻豆一区| 久久中文字幕精品|