匿名考古家 @ 2021-02-10 14:26:18
RT
#include<bits/stdc++.h>
const int N=1e6+20;
long long tree[N],s,n,ans;
long long lowbit(long long x){
return x&(-x);
}
void update(long long i,long long x){
for(;i<=n;i+=lowbit(i)) tree[i]+=x;
}
long long query(long long n){
long long sum=0;
for(;n>0;n-=lowbit(n)) sum+=tree[n];
return sum;
}
int main(){
scanf("%lld",&n);
for(long long i=1;i<=n;++i){
scanf("%lld",&s);
update(s,1);
ans+=(i-query(s));
}
printf("%lld\n",ans);
return 0;
}
请大佬帮看看那错了,谢谢
by Werner_Yin @ 2021-02-10 14:35:34
@匿名考古家 未离散化
by 匿名考古家 @ 2021-02-10 14:36:28
哦,谢谢您