链接:https://www.lydsy.com/JudgeOnline/problem.php?id=3295 思路: 可以将这道题看成倒着插入,这样就可以转化成求逆序对数,用CDQ分治降维,正反用树状数组求两遍逆序对就好了. 这道题还可以用在线的树套树或者可持久化线段树来写.. 实现代码: #include<bits/stdc++.h> using namespace std; #define ll long long ; struct node{ int t,x,y; int kind,…
There are N integers (1<=N<=65537) A1, A2,.. AN (0<=Ai<=10^9). You need to find amount of such pairs (i, j) that 1<=i<j<=N and A[i]>A[j]. Input The first line of the input contains the number N. The second line contains N numbers A…