• <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ù)結(jié)構(gòu)
            国产成年无码久久久久毛片| 国产精品午夜久久| 久久久久亚洲AV成人网| 国产精品久久免费| 久久久久国产精品熟女影院| 亚洲色大成网站www久久九| 一本久道久久综合狠狠躁AV| 性高湖久久久久久久久AAAAA| 精品久久久久久无码人妻热| 久久精品国产99国产精品| 国产精品99久久不卡| 久久精品一区二区三区中文字幕| 亚洲国产天堂久久综合网站| 国产真实乱对白精彩久久| 久久成人精品| 国产精品久久久久免费a∨| 欧美伊人久久大香线蕉综合| 久久精品国产亚洲AV久| 午夜天堂av天堂久久久| 久久久一本精品99久久精品66| 久久精品www人人爽人人| 国产一级持黄大片99久久| 国产精品热久久毛片| 人妻中文久久久久| 亚洲级αV无码毛片久久精品| 久久丫精品国产亚洲av| 国产 亚洲 欧美 另类 久久| 亚洲精品国精品久久99热| 日韩精品久久无码人妻中文字幕| 99久久精品午夜一区二区| 久久久青草青青国产亚洲免观| 亚洲午夜精品久久久久久app| 人妻无码αv中文字幕久久| 青青青青久久精品国产 | 久久久WWW成人免费精品| 三级韩国一区久久二区综合 | 午夜欧美精品久久久久久久| 国内精品久久国产大陆| 理论片午午伦夜理片久久| 久久夜色精品国产噜噜噜亚洲AV| 久久久精品午夜免费不卡|