• <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ù)結構
            伊人久久大香线蕉综合网站| 亚洲中文字幕无码久久精品1| 久久青青草原国产精品免费| 国产精品99久久久久久www| 亚洲国产成人久久精品影视| 日韩电影久久久被窝网| 伊人久久大香线蕉综合5g| 久久久婷婷五月亚洲97号色 | 合区精品久久久中文字幕一区| 国产精品久久久久久久人人看| 久久久精品人妻一区二区三区蜜桃 | 精品久久久久久无码中文野结衣| 久久久高清免费视频| 久久99精品久久久久子伦| 久久久久久毛片免费看| 精品无码久久久久久尤物| 污污内射久久一区二区欧美日韩| 国产亚洲精品美女久久久| 人妻无码精品久久亚瑟影视| 狠色狠色狠狠色综合久久| 久久人妻AV中文字幕| 久久激情亚洲精品无码?V| 久久精品国产网红主播| 国产成人久久精品一区二区三区 | 欧美色综合久久久久久| 久久久中文字幕| 亚洲精品美女久久久久99| 久久伊人精品一区二区三区| 欧美激情精品久久久久久久| 色综合色天天久久婷婷基地| 久久久久人妻精品一区| 亚洲AV无码一区东京热久久| 区亚洲欧美一级久久精品亚洲精品成人网久久久久 | 日韩AV毛片精品久久久| 91久久精品国产成人久久| 高清免费久久午夜精品| 久久国产亚洲高清观看| 国产精品毛片久久久久久久 | 国内精品九九久久精品 | 久久久久国产精品麻豆AR影院| 国产免费久久精品丫丫|