H2. Maximum Crossings (Hard Version) 树状数组,刚开始没有想到。简易版暴力就能过,求在i前面小于等于a[i]的和,熟悉树状数组,一下就能想到是求逆序对。 树状数组:带有部分前缀和的数组。重点复习!!!
#include
#define ll long long
using namespace std;
const int N=2e5+5;
int n,a[N],ans;
int main()
{
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int t;cin>>t;
while(t--)
{
cin>>n;
for(int i=1;i>a[i];
for(int i=1;i>x;
for(int j=x;j
关注
打赏