• <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)解 一路走過(guò)去的路上就直接取最優(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   博問(wèn)   Chat2DB   管理


            国产香蕉97碰碰久久人人| 午夜精品久久影院蜜桃| 色综合久久久久综合体桃花网 | 伊人色综合久久天天| 欧美粉嫩小泬久久久久久久 | 无码乱码观看精品久久| 激情伊人五月天久久综合| 久久亚洲国产成人精品性色| 久久中文字幕一区二区| 久久夜色精品国产噜噜亚洲a| 狠狠色婷婷久久一区二区三区| 久久久久久亚洲精品无码| 亚洲国产美女精品久久久久∴| 久久精品视屏| 久久久久国产亚洲AV麻豆| 国内精品久久久久影院网站| 久久综合久久自在自线精品自| 久久只有这精品99| 国产成人无码精品久久久免费| 久久婷婷成人综合色综合| 三级片免费观看久久| 亚洲国产成人久久综合一区77 | 国产激情久久久久久熟女老人| 国产精品99久久99久久久| 欧美丰满熟妇BBB久久久| 精品久久久久久| 香蕉久久夜色精品国产小说| 久久精品这里只有精99品| 7777精品久久久大香线蕉 | 欧美激情精品久久久久久久| 久久亚洲精品国产精品婷婷| 久久久精品国产免大香伊 | 亚州日韩精品专区久久久| 亚洲国产精品一区二区三区久久| 93精91精品国产综合久久香蕉| 国产精品久久久久久五月尺| 99精品久久久久久久婷婷| 狠狠人妻久久久久久综合| 伊人久久大香线蕉av一区| 97久久精品无码一区二区| 久久久久久精品久久久久|