Kawaii_UKE @ 2023-07-30 14:46:27
#include<bits/stdc++.h>
using namespace std;
int a[50010];
int main()
{
int n,ans=0;;
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a[i];
}
for(int i=1;i<=n;i++)
{
for(int j=i+1;j<=n;j++)
{
if(a[i]>a[j])
ans++;
}
}
cout<<ans;
return 0;
}
by Parrhesiates @ 2023-07-30 15:05:01
超时了吧
by jiangjiangQwQ @ 2023-07-30 15:13:57
这道题要用到归并排序或树状数组。没那么简单滴!