poj3378 树状数组 + 离散化 + 高精度

#include <stdio.h>
#include <string>
#include <string.h>
#include <queue>
#include <stack>
#include <map>
#include <iostream>
#include <stdlib.h>
#include <math.h>
#include <set>
#include <algorithm>
#define inf 0x3f3f3f3f
#define mem0(x , y)  memset(x , y , sizeof(x))
#define ll long long
#define LL long long
#define rep(x , y)   for(int x=0;x<y;x++)
#define per(x , y)   for(int x=y-1;x>=0;x--)
#define lowbit(x) (x & (-x))
#define print(x) printf("%d\n" , x) ;
#define middle int mid = (l + r)/2
#define lson rt<<1 , l , mid
#define rson rt<<1|1 , mid+1, r
#define CASE int T ; int ca = 0 ; read(T) ; while(T--)
#define RT tree[rt]
#define FP freopen("1" , "r" , stdin)
#define mem0(x , y) memset(x , y , sizeof(x))
#define BIN(x) ll bin ; bin = (ll)1 << x ; ///2的x次方
#define E Edge[i]
#define lowbit(x) (x & (-x))
const int MAXN = 500000 ;
const int MAXV = 200000 ;
const int MAXE = 200000 ;
const int mod  = 1e8+7  ;
using namespace std ;
/****************前向星****************
struct edge{
int s , e , w , next ;
bool operator < (const edge & e) const{
return w < e.w ;
}
}Edge[MAXE] ;
int head[MAXV] , hct = 0 ;
Edge[hct].s = s ; Edge[hct].e =e ;Edge[hct].w = w ; Edge[hct].next = head[s] ;
}
/*************************************/
int BIT[1000000] ;
const int MAXB = 1000000 ;
x ++ ;
while(x < MAXB) BIT[x] += val , x += lowbit(x) ;
}
int query(int x){
int ans = 0 ;
while(x) ans += BIT[x] , x -= lowbit(x) ;
return ans ;
}
int hs[1000000] , ch = 0 ;
int da[1000000] ;
int dp[1000000][6] ;
int find(int x){
return lower_bound(hs , hs+ch , x) - hs ;
}
int main(){
ch = 0 ;
rep(i , n) read(da[i]) , hs[ch++] = da[i] ;
sort(hs , hs+ch) ; ch = unique(hs , hs+ch) - hs ;
for(int i=0;i<n;i++) dp[i][1] = 1 ;
for(int l=2;l<=5;l++){
mem0(BIT , 0) ;
for(int i=0;i<n;i++){
dp[i][l] = query(find(da[i])) ;
}
}
int ans = 0 ;
for(int i=0;i<n;i++){
ans += dp[i][5] ;
}
printf("%d\n",ans) ;
}
}


01-19 4675

08-17 414

05-01 337

08-17 318

09-20 422

09-12 272

04-30 3461

05-03 286

03-27 595

11-14 292