归并排序模板!极简版
void Sort(int l,int r){ if(l==r)return; int mid=(l+r)>>1; Sort(l,mid),Sort(mid+1,r); int i=l,j=mid+1,k=l; while(i<=mid&&j<=r){ if(a[i]<=a[j])tmp[k++]=a[i++]; else tmp[k++]=a[j++],ans+=mid-i+1; } while(i<=mid)tmp[k++]=a[i++]; while(j<=r)tmp[k++]=a[j++]; for(i=l;i<=r;i++)a[i]=tmp[i]; } Sort(1,n);