• <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
            求逆序?qū)€數(shù)。我是用離散化+樹狀數(shù)組做的。
            以下是我的代碼:
            /*
             * Author:  lee1r
             * Created Time:  2011/8/5 23:33:01
             * File Name: poj2299.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(500007);

            struct Type
            {
                
            int id,value,num;
            };

            bool cmp1(const Type &a,const Type &b)
            {
                
            return a.value<b.value;
            }

            bool cmp2(const Type &a,const Type &b)
            {
                
            return a.id<b.id;
            }

            int n,bit[kMaxn];
            Type r[kMaxn];
            int64 ans;

            void Add(int x,int delta)
            {
                
            for(int i=x;i<=n;i+=lowbit(i))
                    bit[i]
            +=delta;
            }

            int Sum(int x)
            {
                
            int re(0);
                
            for(int i=x;i>0;i-=lowbit(i))
                    re
            +=bit[i];
                
            return re;
            }

            int main()
            {
                
            //freopen("data.in","r",stdin);
                
                
            while(scanf("%d",&n)==1 && n)
                {
                    
            for(int i=1;i<=n;i++)
                    {
                        scanf(
            "%d",&r[i].value);
                        r[i].id
            =i;
                    }
                    sort(r
            +1,r+n+1,cmp1);
                    
            for(int i=1;i<=n;i++)
                        r[i].num
            =i;
                    sort(r
            +1,r+n+1,cmp2);
                    
                    ans
            =0;
                    memset(bit,
            0,sizeof(bit));
                    
            for(int i=1;i<=n;i++)
                    {
                        Add(r[i].num,
            1);
                        ans
            +=i-Sum(r[i].num-1)-1;
                    }
                    
                    cout
            <<ans<<endl;
                }
                
                
            return 0;
            }
            posted on 2011-08-05 23:44 lee1r 閱讀(270) 評論(0)  編輯 收藏 引用 所屬分類: 題目分類:數(shù)據(jù)結構
            思思久久好好热精品国产| 久久天天躁狠狠躁夜夜av浪潮 | 久久久久久亚洲精品影院| 日本久久中文字幕| 亚洲中文久久精品无码| 久久久精品免费国产四虎| 日韩AV毛片精品久久久| 色婷婷综合久久久久中文一区二区| 亚洲午夜久久久影院伊人| 久久91精品国产91久久户| 久久精品国产亚洲7777| 国产精品免费福利久久| 久久免费大片| 欧美亚洲另类久久综合| 欧美日韩久久中文字幕| 久久久91精品国产一区二区三区| 综合久久精品色| 精品多毛少妇人妻AV免费久久| 精品国产99久久久久久麻豆| 久久无码AV中文出轨人妻| 久久免费国产精品一区二区| 久久久亚洲欧洲日产国码aⅴ| 久久久久亚洲精品中文字幕| 精品国产一区二区三区久久| 无遮挡粉嫩小泬久久久久久久 | 中文字幕无码久久精品青草 | 亚洲美日韩Av中文字幕无码久久久妻妇| 麻豆成人久久精品二区三区免费| 久久久久亚洲AV成人网| 亚洲国产精品久久| 久久精品国产半推半就| 狠狠狠色丁香婷婷综合久久俺| 亚洲中文字幕无码久久2020| 青青草原综合久久大伊人| 欧美日韩成人精品久久久免费看| 7国产欧美日韩综合天堂中文久久久久| 久久精品国产亚洲77777| 久久这里只有精品18| 久久精品国产亚洲AV无码麻豆| 亚洲精品无码专区久久久| 久久久亚洲裙底偷窥综合|