全RE
查看原帖
全RE
1015339
cosmicvoyage楼主2023/10/20 18:45
#include <cstdio>
using namespace std;
inline long long read()
{
    long long s = 0,w = 1;
    char ch = getchar();
    while(ch < '0' || ch > '9')
    {
        if(ch == '-') 
        {
            w = -1;
        }
        ch = getchar();
    }
    while(ch >= '0' && ch <= '9')
    {
        s = (s << 1) + (s << 3) + (ch ^ 48);
        ch = getchar();
    }
    return s * w;
}
inline void write(long long x)
{
    if(x < 0) 
    {
        putchar('-'),x = -x;
    }
    if(x > 9) 
    {
        write(x / 10);
    }
    putchar(x % 10 + '0');
}
long long a[200005],n,m,ans;
signed main()
{
	n=read();
	for(int i=1;i<=n;i++)
    {
		m=read();
		for(int j=m;j;j-=(j&(-j)))
            ans-=a[j];ans+=i-1;
		for(int j=m;j<=n;j+=(j&(-j)))
            a[j]++;
	}
	write(ans);
    return 0;
}

有大佬帮忙解决一下吗
2023/10/20 18:45
加载中...