• <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>
            心如止水
            Je n'ai pas le temps
            posts - 400,comments - 130,trackbacks - 0
            哈夫曼樹(shù)。使用堆來(lái)維護(hù)。
            以下是我的代碼:
            /*
             * Author:  lee1r
             * Created Time:  2011/8/5 23:46:40
             * File Name: poj3253.cpp
             
            */
            #include
            <iostream>
            #include
            <sstream>
            #include
            <fstream>
            #include
            <vector>
            #include
            <list>
            #include
            <deque>
            #include
            <queue>
            #include
            <stack>
            #include
            <map>
            #include
            <set>
            #include
            <bitset>
            #include
            <algorithm>
            #include
            <cstdio>
            #include
            <cstdlib>
            #include
            <cstring>
            #include
            <cctype>
            #include
            <cmath>
            #include
            <ctime>
            #define L(x) ((x)<<1)
            #define R(x) (((x)<<1)+1)
            #define Half(x) ((x)>>1)
            #define lowbit(x) ((x)&(-(x)))
            using namespace std;
            const int kInf(0x7f7f7f7f);
            const double kEps(1e-8);
            typedef 
            long long int64;
            typedef unsigned 
            long long uint64;

            const int kMaxn(20007);

            int n;
            int64 ans;

            int main()
            {
                
            //freopen("data.in","r",stdin);
                
                
            while(scanf("%d",&n)==1)
                {
                    priority_queue
            < int,vector<int>,greater<int> > q;
                    
                    
            for(int i=1;i<=n;i++)
                    {
                        
            int t;
                        scanf(
            "%d",&t);
                        q.push(t);
                    }
                    
                    ans
            =0;
                    
            while(q.size()>1)
                    {
                        
            int t(q.top());q.pop();
                        t
            +=q.top();q.pop();
                        q.push(t);
                        ans
            +=t;
                    }
                    
            //ans+=q.top();
                    
                    cout
            <<ans<<endl;
                }
                
                
            return 0;
            }
            posted on 2011-08-05 23:59 lee1r 閱讀(659) 評(píng)論(0)  編輯 收藏 引用 所屬分類: 題目分類:數(shù)據(jù)結(jié)構(gòu)
            久久综合九色综合网站| 国产精品久久99| 一本色道久久88精品综合| 亚洲国产精品成人久久| 嫩草影院久久国产精品| 亚洲精品第一综合99久久| 久久久久高潮综合影院| 久久国产一区二区| 精品久久久无码21p发布| 国产精品欧美亚洲韩国日本久久| 久久中文字幕视频、最近更新 | 久久人妻无码中文字幕| 成人久久综合网| 无遮挡粉嫩小泬久久久久久久| 麻豆精品久久久一区二区| 久久夜色精品国产噜噜噜亚洲AV| 久久AAAA片一区二区| 色综合久久中文综合网| 无码国内精品久久人妻蜜桃| 久久中文字幕视频、最近更新| 亚洲国产精品久久久久婷婷老年 | 久久久久婷婷| 一本大道加勒比久久综合| 亚洲精品国产美女久久久| 亚洲国产成人精品无码久久久久久综合 | 久久妇女高潮几次MBA| 精品久久综合1区2区3区激情| 久久久亚洲欧洲日产国码aⅴ| 色妞色综合久久夜夜| 国产精品久久久久久久人人看| 青青青青久久精品国产h| 久久九九有精品国产23百花影院| 久久久久免费看成人影片| 韩国免费A级毛片久久| 久久综合久久综合亚洲| 国产激情久久久久影院| 国产精品无码久久四虎| 国产综合久久久久| 久久久精品免费国产四虎| 91超碰碰碰碰久久久久久综合| 99久久er这里只有精品18|