im new to spoj and started solving some simple problems but on this problem im getting runtime error i dont know why it is??my code looks fine.
task: INVCNT - Inversion Count
my solution:
#include<bits/stdc++.h>
using namespace std;
int main(){
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
const int maxa=1e5;
int n,t,a[maxa];
cin>>t;
while(t--){
cin>>n;
for(int i=0;i<n;i++)
cin>>a[i];
int inv_count = 0;
for (int i=0;i<n-1;i++)
for (int j=i+1;j<n;j++)
if (a[i]>a[j])
inv_count++;
cout<<inv_count<<endl;
}
return 0;
}
cant figure out why im getting runtime error but the code works fine on my ide?