#include #include using namespace std; const int N=200000; void merge__(vector& arr, vector& tmp, int l, int mid, int r, int& ret) { int i = l, j = mid + 1, k = 0; while (i <= mid && j <= r) { if (arr[i] > arr[j]) { tmp[k++] = arr[j++]; ret += (mid - i + 1); } else { tmp[k++] = arr[i++]; } } while (i <= mid) { tmp[k++] = arr[i++]; } while (j <= r) { tmp[k++] = arr[j++]; } for (k = 0, i = l; i <= r; ++i, ++k) { arr[i] = tmp[k]; } } void merge_sort__(vector& arr, vector& tmp, int l, int r, int& ret) { if (l >= r) { return; } int mid = l + ((r - l) >> 1); merge_sort__(arr, tmp, l, mid, ret); merge_sort__(arr, tmp, mid + 1, r, ret); merge__(arr, tmp, l, mid, r, ret); } int InversePairs(vector& nums) { // write code here int ret = 0; // 在最外层开辟数组 vector tmp(nums.size()); merge_sort__(nums, tmp, 0, nums.size() - 1, ret); return ret; } int main() { vector q; int n,a; cin >> n; int result; for(int i=0;i>a; q.push_back(a); } for(int i=0;i