• <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 閱讀(132) 評論(0)  編輯 收藏 引用
            女人高潮久久久叫人喷水| www久久久天天com| 色综合久久中文字幕综合网| 香蕉久久影院| 久久精品国产免费| 久久最新免费视频| 99久久久精品免费观看国产| 久久影院午夜理论片无码| 亚洲精品乱码久久久久久按摩 | 欧美亚洲国产精品久久久久| 亚洲精品无码久久久久sm| 青草久久久国产线免观| 青青热久久综合网伊人| 久久亚洲精品无码AV红樱桃| 久久天天躁狠狠躁夜夜2020老熟妇| 亚洲国产精品无码久久久秋霞2| 日本久久久久久中文字幕| 久久精品99久久香蕉国产色戒| 久久久久国产一区二区| 久久99中文字幕久久| 国产精品99久久久久久宅男小说| 伊人久久综在合线亚洲2019| 久久婷婷五月综合色高清| 亚洲精品乱码久久久久久不卡| 久久精品无码一区二区三区免费 | 久久精品成人免费国产片小草 | 久久精品国产亚洲AV无码偷窥| 国产精品久久久久久久app | 久久丫精品国产亚洲av不卡 | 狠狠精品久久久无码中文字幕 | 日产久久强奸免费的看| 青青国产成人久久91网| 亚洲国产精品久久66| 色综合久久精品中文字幕首页| 2021精品国产综合久久| 狠狠色噜噜狠狠狠狠狠色综合久久 | 国内精品久久久久影院优| 久久免费的精品国产V∧| 国产精品久久久亚洲| 久久精品九九亚洲精品| 伊人久久综在合线亚洲2019|