The Inversions...


Problem Statement :

https://www.codechef.com/ITRX2016/problems/ITRIX16C

Problem Solution :

#include<iostream>
#include<algorithm>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin>>t;
    while(t--)
    {
      long long int n,ans;
      cin>>n;
      ans=n*(n-1)/2;
      long long int t;
      while(n--)
        cin>>t;
      cout<<ans<<endl;
    }
    return 0;
}

No comments:

Post a comment