Dirge_ @ 2020-07-12 16:03:28
蒟蒻也不知道为什么会RE啊/kk
数组貌似也没有开小,本地运行也没有问题啊,求大佬帮忙QWQ
代码:
#include<bits/stdc++.h>
using namespace std;
long long n,m,i,x,ans,a[5000005];
long long lowbit(long long x)
{
return x&(-x);
}
void add(long long x)
{
for(long long k=x;k<=n;k+=lowbit(k)) a[k]++;
}
long long sum(long long x)
{
long long s=0;
for(long long q=x;q;q-=lowbit(q)) s+=a[q];
return s;
}
int main()
{
scanf("%lld",&n);
for(i=1;i<=n;i++)
{
scanf("%lld",&x);
add(x);
ans+=sum(n)-sum(x);
}
printf("%lld",ans);
return 0;
}
谢谢大家啊啊啊啊(我一定有sb错误
by Ryo_Yamada @ 2020-10-22 06:07:36
烤咕
by Dirge_ @ 2020-10-27 22:31:08
嗯,考个古,感觉我当时挺xxs的(
by 新版米奇奇米 @ 2020-11-28 22:49:35
Orz!
by Dirge_ @ 2020-12-21 22:20:05
@新版米奇奇米 哇您是怎么考古考出这个帖子的啊/jk
by 新版米奇奇米 @ 2020-12-27 21:27:39
@玉希亚 忘记了...