Description
Input
Output
Sample Input
3 1 2 2 1
Sample Output
1
Data Constraint
分析
简单的树状数组求逆序对,答案等于逆序对数-k,注意当k大于逆序对数输出零
#include#include #include #include #define lowbit(x) x&-xusing namespace std;typedef long long ll;const int N=1e5+10;ll t[N],a[N],b[N],k;int n,cnt;void Add(int x) { for (int i=x;i