1 //树形DP+树状数组 HDU 5877 Weak Pair 2 // 思路:用树状数组每次加k/a[i],每个节点ans+=Sum(a[i]) 表示每次加大于等于a[i]的值 3 // 这道题要离散化 4 5 #include6 using namespace std; 7 #define LL long long 8 typedef pair pii; 9 const double inf = 123456789012345.0;10 const LL MOD =100000000LL;11 const int N = 2e5+10;12 const int maxx = 200010; 13 #define clc(a,b) memset(a,b,sizeof(a))14 const double eps = 1e-7;15 void fre() {freopen("in.txt","r",stdin);}16 void freout() {freopen("out.txt","w",stdout);}17 inline int read() { int x=0,f=1;char ch=getchar();while(ch>'9'||ch<'0') { if(ch=='-') f=-1; ch=getchar();}while(ch>='0'&&ch<='9') {x=x*10+ch-'0';ch=getchar();}return x*f;}18 19 map ma;20 LL a[N];21 LL c[N],b[N];22 LL in[N];23 vector g[N];24 LL lowbit(LL x){ return x&(-x);}25 LL add(LL x,int t){26 while(x>0){27 c[x]+=t;28 x-=lowbit(x);29 }30 }31 LL Sum(LL x){32 LL sum=0;33 while(x