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…
这个是逆序对的裸题哇 归并排序或者树状数组~ 树状数组的话需要离散化一下··· emm确实很水很水很水··· 归并排序: #include <cstdio> #include <algorithm> #include <cstring> #include <iostream> using namespace std; +; int a[maxn]; int n; int t[maxn]; long long ans; void merge(int L,int…
求逆序数对 归并排序 #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> using namespace std; int a[71010], b[71010]; long long cnt; void merge_sort(int *A, int x, int y, int *T) { if(y-x > 1) { int m = x+(y-x)/2…