彩笔求助,一片紫色(

P1908 逆序对

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 Dirge_ @ 2020-07-14 10:07:19

@Lattle_Car 。。。像你这种人就是欠%(话说你真的好闲啊


by Laser_Crystal @ 2020-07-14 10:11:47

@玉希亚 (某人在其友链中曰:scw就是欠揍(逃


by Dirge_ @ 2020-07-14 10:20:59

@Lattle_Car 哦,是吗?哈哈哈哈哈哈哈哈哈真好笑


by pqliuyqq @ 2020-07-14 17:47:14

考古(逃


by Dirge_ @ 2020-07-16 00:40:32

?那么多人考古(


by Commonplace_Magic @ 2020-07-19 15:20:17

?这帖变水帖了?


by Yaixy @ 2020-07-20 13:43:32

???


by PRAGMATISM @ 2020-08-02 17:08:25

?这帖变水帖了?


by 傅天宇 @ 2020-08-07 22:26:18

@玉希亚 神仙吧


by Yaixy @ 2020-08-08 09:08:17

@玉希亚 屑吧


上一页 | 下一页