Skies @ 2020-07-19 11:09:06
#include<bits/stdc++.h>
using namespace std;
const int N=5e5+5;
int a[N],c[N];
int n;
int ask(int x)
{
int ans=0;
for(;x>0;x-=x&-x)ans+=c[x];
return ans;
}
void add(int x,int y)
{
for(;x<=n;x+=x&-x)c[x]+=y;
}
int main()
{
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a[i];
// add(i,1);
}
int ans=0;
for(int i=n;i>0;i--)
{
ans+=ask(a[i]-1);
add(a[i],1);
}
cout<<ans;
return 0;
}
all RE,help!!!
by _5011_ @ 2020-07-19 11:23:39
这题正解不是莫队二次离线吗
by lowAltitudeFlyer @ 2020-07-19 11:24:10
/fad
by critnos @ 2020-07-19 11:25:46
@陈照然666
by Integricode_26 @ 2020-07-19 11:30:39
@mcyl35 那是我们班上一个dalao,我真不会,我前面说了我图论方面真的有点caiji
by critnos @ 2020-07-19 11:31:46
emm
by Integricode_26 @ 2020-07-19 11:33:00
@LJC00175 对对对,树状数组是图论(我太cai了,只知道归排和树状数组/ll)
by Integricode_26 @ 2020-07-19 11:33:26
@mcyl35 ?
by Aleph1022 @ 2020-07-19 11:34:03
@陈照然666 树状数组您也会的话干嘛一上来就说这题考察的归排用别的方法会 TLE
by lnwsh @ 2020-07-19 11:35:15
同意楼上。
by Integricode_26 @ 2020-07-19 11:35:28
@alpha1022 口误(sorry