Why this TLE occur u=in my solution of euron problem

https://www.codechef.com/viewsolution/62955036
'#include <bits/stdc++.h>
using namespace std;

int main()
{
long long n,i,j,c=0;
cin>>n;
long long a[n];
for(i=0;i<n;i++){
cin>>a[i];
}
for(i=n-1;i>=0;i–){
for(j=i-1;j>=0;j–){
if(a[i]<a[j]){
c=c+1;
}
}
}
cout<<c;

}

How to overcome this

Hey @shahi03
Thanks for sharing your doubt.

The time complexity of your code is O(n*n) and n is in the order of 10^5. As 10^{10} operation cannot be done in 1 second time limit that is why your are getting TLE. Try using merge sort to optimize your code to Nlog(N).