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

            oyjpArt ACM/ICPC算法程序設(shè)計(jì)空間

            // I am new in programming, welcome to my blog
            I am oyjpart(alpc12, 四城)
            posts - 224, comments - 694, trackbacks - 0, articles - 6

            PKU1042 Gone Fishing

            Posted on 2007-02-17 13:58 oyjpart 閱讀(1634) 評(píng)論(0)  編輯 收藏 引用

            簡(jiǎn)單題 直接枚舉結(jié)束湖泊+貪心選擇就可以了
            為什么可以貪心?(反正你要取的是最優(yōu)解 你可以假定自己知道最優(yōu)解 一路走過去的路上就直接取最優(yōu)解就可以了)
            因?yàn)榧?xùn)的時(shí)候這個(gè)題目莫名WA 故再A一遍 以解心頭之恨!
            using namespace std; 不能用time G++ CE多次 faint
            Gone Fishing
            Solution:
            // by oyjpArt
            #include <iostream>
            #include <queue>
            using namespace std;
            const int N = 30;
            struct node {int nf, idx; void set(int nn, int ii) {nf = nn; idx = ii;}};
            int nl, time, f[N], t[N], d[N], totf, stay[N], beststay[N];
            typedef priority_queue<node> PQ;

            bool operator<(const node&a, const node& b) { if(a.nf == b.nf) return a.idx > b.idx; return a.nf < b.nf; }

            int main () {
            ?int i, j;
            ?while(scanf("%d", &nl), nl) {
            ??scanf("%d", &time);
            ??time *= 12;
            ??int maxf = -1;
            ??for(i = 0; i<nl; i++) scanf("%d", f+i);
            ??for(i = 0; i<nl; i++) scanf("%d", d+i);
            ??for(i = 0; i<nl-1; i++) scanf("%d", t+i);
            ??for(i = 0; i<nl; i++) {?
            ???memset(stay, 0, sizeof(stay));
            ???totf = 0;
            ???if(i>0)?time -= t[i-1];
            ???node now;
            ???PQ pq;
            ???for(j = 0; j<=i; j++)
            ???{?now.set(f[j], j); pq.push(now);}
            ???for(j = 0; j<time; j++) {
            ????now = pq.top();
            ????pq.pop();
            ????stay[now.idx] += 5;
            ????totf += now.nf;
            ????now.nf -= d[now.idx];
            ????if(now.nf < 0) now.nf = 0;
            ????pq.push(now);
            ???}
            ???if(totf > maxf) {
            ????maxf = totf;
            ????memcpy(beststay, stay, sizeof(stay));
            ???}
            ??}
            ??printf("%d", beststay[0]);
            ??for(i = 1; i<nl; i++) printf(", %d", beststay[i]);
            ??printf("\nNumber of fish expected: %d\n\n", maxf);
            ?}
            ?return 0;
            }


            只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            久久av无码专区亚洲av桃花岛| 97精品伊人久久大香线蕉| 99久久国产综合精品麻豆| 国产精品成人99久久久久| 久久久久久青草大香综合精品| 思思久久99热免费精品6| 欧美黑人激情性久久| 狠狠色丁香久久婷婷综合五月| 99久久99久久精品国产片| 伊人久久大香线蕉成人| 久久婷婷成人综合色综合| 久久精品国产99国产精品| 亚洲中文字幕无码久久综合网| 夜夜亚洲天天久久| 亚洲中文久久精品无码| 久久99久久无码毛片一区二区| 久久久久人妻一区二区三区 | 久久精品久久久久观看99水蜜桃| 97久久精品无码一区二区天美| 一本色道久久综合狠狠躁| 久久久久亚洲AV片无码下载蜜桃| 久久中文字幕一区二区| 久久久久久久久久久| 欧美亚洲日本久久精品| 久久久久四虎国产精品| 久久w5ww成w人免费| 亚洲中文字幕久久精品无码APP| 人妻精品久久久久中文字幕| 情人伊人久久综合亚洲| 狠狠久久亚洲欧美专区| 久久精品中文字幕无码绿巨人| 国内精品久久久久影院亚洲| 热RE99久久精品国产66热| 狠狠久久综合伊人不卡| 久久播电影网| 久久综合色之久久综合| 久久涩综合| 久久久久高潮综合影院| 日韩人妻无码一区二区三区久久99| 色欲综合久久躁天天躁| 99久久国产亚洲综合精品|