• <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>
            隨筆-65  評論-6  文章-0  trackbacks-0
             1 #include <iostream>
             2 #include <algorithm>
             3 #include <stack>
             4 #include <cstring>
             5 using namespace std;
             6 #define inf 0x7ffffff
             7 struct data1 {
             8     char name[101];
             9     int deadline,day;
            10 };
            11 data1 subs[20];
            12 struct data2 {
            13     int score;
            14     int pos;
            15     int last;
            16     int day;
            17 };
            18 data2 dp[40000];
            19 
            20 int main(){
            21     freopen("in.txt","r",stdin);
            22     int n,cas,i,j,now,last,temp,Max;
            23     scanf("%d",&cas);
            24     while (cas--){
            25         scanf("%d",&n);
            26         Max=(1<<n);
            27         for(i=0;i<n;i++){
            28             getchar();
            29             scanf("%s %d %d",subs[i].name,&subs[i].deadline,&subs[i].day);
            30         }
            31         dp[0].score=dp[0].day=0;
            32         for(i=1;i<Max;i++){
            33             dp[i].score=inf;
            34             for(j=n-1;j>=0;j--){
            35                 if(i&(1<<j)){//第j個課程選中后
            36                     now=i;
            37                     last=i-(1<<j);
            38                     temp=0;
            39                     if(dp[last].day+subs[j].day>subs[j].deadline)
            40                         temp=dp[last].day+subs[j].day-subs[j].deadline;
            41                     if(dp[last].score+temp<dp[now].score){
            42                         dp[now].score=dp[last].score+temp;
            43                         dp[now].day=dp[last].day+subs[j].day;
            44                         dp[now].pos=j;
            45                         dp[now].last=last;
            46                     }
            47                 }
            48             }
            49         }
            50         printf("%d\n",dp[Max-1].score);
            51         stack<int> sta;
            52         int p=Max-1;
            53         while (p!=0){
            54             sta.push(dp[p].pos);
            55             p=dp[p].last;
            56         }
            57         while (!sta.empty()){
            58             int no=sta.top();
            59             sta.pop();
            60             printf("%s\n",subs[no].name);
            61         }
            62     }
            63 
            64     return 0;
            65 }
            posted on 2012-07-10 00:17 Leo.W 閱讀(123) 評論(0)  編輯 收藏 引用
            国产精品青草久久久久福利99| 一本久久免费视频| 99久久成人国产精品免费| 久久国产亚洲精品无码| 91久久婷婷国产综合精品青草| 97精品国产91久久久久久| 精品久久久久中文字幕一区| 久久亚洲视频| 久久夜色精品国产噜噜亚洲AV| 国产精品久久久久久| 一本大道加勒比久久综合| 久久久久久久综合狠狠综合| 精品少妇人妻av无码久久| 免费精品久久久久久中文字幕 | 久久亚洲精品视频| 一级做a爰片久久毛片看看| 午夜精品久久久久久久| 久久免费国产精品| 久久亚洲高清观看| 久久99精品久久久久久hb无码 | 国产毛片久久久久久国产毛片| 久久精品免费一区二区| 大香网伊人久久综合网2020| 亚洲va久久久噜噜噜久久天堂| 久久久久99精品成人片牛牛影视| 亚洲中文精品久久久久久不卡| 欧美精品一区二区久久 | 久久国内免费视频| 精品久久久久久无码中文字幕| 国产综合久久久久久鬼色| 久久久国产打桩机| 久久精品免费一区二区| 中文字幕久久精品 | 久久久久亚洲?V成人无码| 亚洲国产精品久久久久网站| 国产亚洲精久久久久久无码| 久久久久久九九99精品| 99精品国产在热久久无毒不卡| 久久er99热精品一区二区| 久久国产精品无码一区二区三区 | 久久97久久97精品免视看|