其实.,我没有AC,因为...高进度不会,所以没有搞.ok,这个是我直接一次后的代码.是为了以后再做这一题用的
#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 read(x) scanf("%d",&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 ;
void add_edge(int s,int e,int w){
Edge[hct].s = s ; Edge[hct].e =e ;Edge[hct].w = w ; Edge[hct].next = head[s] ;
head[s] = hct ++ ;
}
/*************************************/
int BIT[1000000] ;
const int MAXB = 1000000 ;
void add(int x,int val){
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(){
int n ;while(read(n)!=EOF){
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])) ;
add(find(da[i]) , dp[i][l-1]) ;
}
}
int ans = 0 ;
for(int i=0;i<n;i++){
ans += dp[i][5] ;
}
printf("%d\n",ans) ;
}
}