Code review of Codeforces 1324D

// using policy based data structure
#include<bits/stdc++.h>

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,
tree_order_statistics_node_update> PBDS;

int main()
{
PBDS Pos;
PBDS Neg;
int n;cin>>n;

long int teacher[n];
long int student[n];
long int diff[n];
long int cnt=0;
for(int i=0;i<n;i++)
{
    cin>>teacher[i];
}
for(int i=0;i<n;i++)
{
    cin>>student[i];
}
for(int i=0;i<n;i++)
{
   diff[i]=teacher[i]-student[i];
}
for(int i=0;i<n;i++)
{
    if(diff[i]==0)
    {
        int key;
        key=Pos.order_of_key({diff[i],i});
        cnt+=(Pos.size()-key);
        Pos.insert({diff[i],i});
    }
    else if(diff[i]>0)
    {
        int key;

        // positive side
        cnt+=Pos.size();

        // negative side
        key=Neg.order_of_key({diff[i],i});
        cnt+=key;
        Pos.insert({diff[i],i});

    }
    else{
        int key;
        key=Pos.order_of_key({abs(diff[i]),i});
        cnt+=(Pos.size()-key);
        Neg.insert({abs(diff[i]),i});
    }
}
cout<<cnt<<endl;
return 0;

}

Can you please review my code?
Pos and Neg are there to maintain (Positive value & zero) and negative value separately. The absolute value of negative number is stored in Neg.

hello @subhamjaiswal885

vide solution is already available in ur course pls check that. and if u find any difficulty then pls let me know

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.