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

            欧美一区二区三区久久综合 | 亚洲精品乱码久久久久久自慰| 久久成人国产精品| 人妻无码久久一区二区三区免费| 亚洲欧美日韩久久精品| 伊人久久国产免费观看视频| 亚洲Av无码国产情品久久| 欧美一级久久久久久久大片| 亚洲精品成人久久久| 久久福利资源国产精品999| 久久久国产精品| 综合久久一区二区三区 | 久久国产精品无码网站| 久久夜色精品国产亚洲av| 亚洲午夜无码久久久久小说| 久久香综合精品久久伊人| 久久综合香蕉国产蜜臀AV| 精品一区二区久久久久久久网站| 欧美777精品久久久久网| 精品久久久久中文字幕一区| 免费无码国产欧美久久18| 久久精品人人做人人爽电影蜜月| 久久这里只有精品久久| 亚洲一区精品伊人久久伊人| 国产精品久久久久影视不卡| 无码国内精品久久人妻麻豆按摩| 亚洲国产精品无码成人片久久| 国内精品伊人久久久久网站| 狠狠综合久久AV一区二区三区| 亚洲国产精品久久| 久久久久久国产a免费观看不卡| 国内精品久久久久影院日本| 天堂久久天堂AV色综合| 色综合久久中文色婷婷| 久久夜色精品国产噜噜亚洲a| 亚洲伊人久久成综合人影院 | 久久99热这里只频精品6| 久久99国产精品二区不卡| 久久久久久精品成人免费图片| 国产精品VIDEOSSEX久久发布| 日韩乱码人妻无码中文字幕久久|