• <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无码| 亚洲国产精品成人久久| 久久777国产线看观看精品| 久久免费的精品国产V∧| jizzjizz国产精品久久| 久久久99精品成人片中文字幕| 合区精品久久久中文字幕一区 | 99久久人妻无码精品系列蜜桃| 久久九九青青国产精品| 伊人久久大香线蕉综合网站| 久久久久亚洲av无码专区导航| 久久久久久久国产免费看| 久久精品一本到99热免费| 狠狠88综合久久久久综合网| 欧美久久综合九色综合| 国产91久久精品一区二区| 91精品国产9l久久久久| 国产午夜精品久久久久九九| 久久精品中文字幕一区| 青青草原1769久久免费播放| 亚洲精品乱码久久久久久蜜桃图片 | 中文字幕人妻色偷偷久久| 久久福利青草精品资源站| 久久人妻少妇嫩草AV蜜桃| 国产亚洲精久久久久久无码AV| 久久人人爽人人爽人人AV| 久久久久亚洲精品中文字幕 | 久久无码人妻一区二区三区| 国内精品久久久久久久coent| 久久国产免费观看精品3| 久久中文字幕人妻丝袜| 日韩va亚洲va欧美va久久| 国产成人久久精品二区三区| 久久久无码一区二区三区| 无遮挡粉嫩小泬久久久久久久| 久久久亚洲AV波多野结衣| 色天使久久综合网天天| 久久综合给合综合久久| 久久中文字幕视频、最近更新| 一本久久a久久精品综合夜夜| 亚洲国产二区三区久久|