• <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算法程序設計空間

            // 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) 評論(0)  編輯 收藏 引用

            簡單題 直接枚舉結束湖泊+貪心選擇就可以了
            為什么可以貪心?(反正你要取的是最優解 你可以假定自己知道最優解 一路走過去的路上就直接取最優解就可以了)
            因為集訓的時候這個題目莫名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;
            }

            久久精品中文字幕一区| 国产欧美久久一区二区| 亚洲精品国产综合久久一线| 最新久久免费视频| 人妻无码久久一区二区三区免费| 精品免费tv久久久久久久| 国产精品综合久久第一页| 久久人做人爽一区二区三区| 丁香色欲久久久久久综合网| 欧美亚洲国产精品久久蜜芽| 久久精品国产亚洲av麻豆图片| 久久久久久亚洲Av无码精品专口 | 午夜天堂av天堂久久久| 情人伊人久久综合亚洲| 亚洲综合熟女久久久30p| 久久最新精品国产| 久久婷婷五月综合国产尤物app| 国产精品无码久久四虎| 996久久国产精品线观看| 久久99九九国产免费看小说| 国产激情久久久久影院| 91精品国产高清91久久久久久| 久久笫一福利免费导航| 久久人人爽人人澡人人高潮AV | 亚洲AV伊人久久青青草原| 欧美综合天天夜夜久久| 国产美女久久久| 俺来也俺去啦久久综合网| 久久久久久亚洲精品成人| 亚洲午夜无码久久久久| 区久久AAA片69亚洲| 国内精品综合久久久40p| 亚洲国产精品嫩草影院久久| 日日狠狠久久偷偷色综合免费 | 久久精品国产亚洲77777| 久久狠狠高潮亚洲精品| 97久久超碰成人精品网站| 久久久久99精品成人片欧美| 久久精品国产久精国产思思| 国产精品久久久久jk制服| 99久久精品免费看国产免费|