QZY2008 @ 2021-09-29 19:21:51
RT
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=1e6+1;
ll c[N];//树状数组
inline ll lowbit(ll x){
return x&-x;
}
inline void updata(ll x,ll y){
for (;x<N;x+=lowbit(x))
c[x]+=y;
}
inline ll query(ll len){
ll res=0;
for (;len;len-=lowbit(len))
res+=c[len];
return res;
}
ll n;
ll ans=0;
ll num;
int main(){
scanf("%lld",&n);
for (ll i=1;i<=n;i++){
scanf("%lld",&num);
updata(num,1);
ans+=i-query(num);
}
printf("%lld\n",ans);
}
by Aishiteru_zwy @ 2021-09-29 19:25:40
又一次捉到活的qzy
by QZY2008 @ 2021-09-29 19:26:59
@ZWYTYT ???
by 小小蒟弱 @ 2021-10-04 16:55:02
离散化
by JiaRans_Dog @ 2021-10-08 08:00:45
RE0?