___LiangQiChao___ @ 2024-04-21 14:54:20
#include<bits/stdc++.h>
using namespace std;
int a[10005];
int main(){
int n,sum=0;
cin>>n;
for(int i=0;i<n;i++){
cin>>a[i];
}
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
if(a[i]>a[j]&&i<j) sum++;
}
}
cout<<sum;
return 0;
}
by __LePetitPrince__ @ 2024-04-21 15:04:13
这是树状数组啊,你这样写复杂度不对
by szh_AK_all @ 2024-04-21 15:04:37
@LiangQiChao
你这是错误的暴力写法,建议学习正解。
by szh_AK_all @ 2024-04-21 15:06:28
梁启超是吧
by dongrunxuan @ 2024-04-21 15:09:16
@LiangQiChao 数组开小了,要开到
by Grammar__hbw @ 2024-04-21 15:21:09
看看题面最后一句
by Hughpig @ 2024-04-21 15:30:16
@LiangQiChao 正解是O(nlogn)
by ___LiangQiChao___ @ 2024-04-21 21:35:58
@Hughpig @Grammar_hbw @dongrunxuan @szh_AK_all @szh_AK_all @LePetitPrince 深表感谢!!!