• <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 閱讀(1630) 評論(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;
            }

            久久99久久99精品免视看动漫 | 综合久久一区二区三区| 亚洲国产精品久久久久久| 亚洲中文字幕久久精品无码喷水 | 18禁黄久久久AAA片| 亚洲综合日韩久久成人AV| 亚洲精品成人久久久| 久久香蕉国产线看观看猫咪?v| 欧美激情精品久久久久久| 久久99精品久久久久久不卡| 欧美日韩成人精品久久久免费看| 国产精品久久新婚兰兰| 欧美亚洲国产精品久久高清| 人妻无码精品久久亚瑟影视| 伊人色综合久久天天网| 一本综合久久国产二区| 久久久国产打桩机| 日韩人妻无码一区二区三区久久| 久久青青草原国产精品免费 | 国产精品亚洲综合久久| 久久久噜噜噜久久中文字幕色伊伊| 久久久黄色大片| 天天爽天天爽天天片a久久网| 久久亚洲欧美日本精品| 久久WWW免费人成—看片| 欧美精品丝袜久久久中文字幕 | 亚洲精品WWW久久久久久 | 久久A级毛片免费观看| 国产精品99久久久久久董美香| 一本久久a久久精品亚洲| 久久精品国产亚洲av高清漫画| 久久最近最新中文字幕大全 | 久久久午夜精品| 麻豆一区二区99久久久久| 热久久国产精品| 2021国产精品久久精品| 久久福利青草精品资源站免费| 婷婷久久五月天| 97久久超碰国产精品旧版| 久久夜色精品国产噜噜噜亚洲AV | 久久国产成人午夜aⅴ影院|