• <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久久国产综合精品| 一本色道久久HEZYO无码| 精品久久久久久久久中文字幕| 性做久久久久久久| 久久人与动人物a级毛片| 佐藤遥希在线播放一二区 | 国产精品久久久久天天影视| 东方aⅴ免费观看久久av| 亚洲伊人久久综合影院| 亚洲?V乱码久久精品蜜桃| 亚洲精品无码久久毛片| 综合久久给合久久狠狠狠97色| 久久精品国产日本波多野结衣 | 国产成人精品综合久久久| 999久久久无码国产精品| 久久精品草草草| 久久黄视频| 一本久久综合亚洲鲁鲁五月天亚洲欧美一区二区 | 国产亚州精品女人久久久久久 | 97久久精品人妻人人搡人人玩| 久久综合久久自在自线精品自 | 亚洲国产精品无码久久久秋霞2| 亚洲av成人无码久久精品| 久久久精品午夜免费不卡| 国产精品丝袜久久久久久不卡 | 狠狠色丁香婷婷综合久久来来去 | 精品久久久久久无码中文字幕| 久久91精品综合国产首页| 波多野结衣久久一区二区| 国产亚洲精品美女久久久| 国产精品美女久久久久AV福利 | 欧美丰满熟妇BBB久久久| 国产精品欧美久久久天天影视| 亚洲国产成人久久综合碰碰动漫3d| 久久99亚洲综合精品首页 | 日日躁夜夜躁狠狠久久AV| 精品多毛少妇人妻AV免费久久| 亚洲国产欧洲综合997久久| 亚洲精品高清国产一久久| 久久精品国产99国产精品亚洲|