I am trying to make my inversion counting program run faster since I am continuously getting TLE. I used C++ and this is my code
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
int n;
int count = 0;
cin >> n;
int arr[n];
for(int i = 0; i < n; i++)
{
cin >> arr[i];
}
for(int i = 0; i < n - 1; i++)
{
for(int j = i + 1; j < n; j++)
if(arr[i] > arr[j])
{
count++;
}
}
cout << count;
}
Help please!