I am getting runtime error on my code please help!
Problem=https://www.codechef.com/problems/FAIRELCT
Mycode= #include <bits/stdc++.h> // header file includes every Standard library
using namespace std;
long long sum(long long vec[],long long n)
{
long long summ=0;
for(long long i=0;i<n;i++)
{
summ+=vec[i];
}
return summ;
}
int main() {
long long t;
cin>>t;
while(t–)
{
long long n,m,result=0;
cin>>n>>m;
long long vecn[n];
long long vecm[m];
for(long long i=0;i<n;i++)
{
cin>>vecn[i];
}
for(long long i=0;i<m;i++)
{
cin>>vecm[i];
}
long long j=m-1;
long long i=0;
sort(vecn,vecn+n);
sort(vecm,vecm+m);
while(((j>=0) and (i<m))and (sum(vecn,n)<=sum(vecm,m)))
{
swap(vecn[i],vecm[j]);
result++;
j--;
i++;
}
if(sum(vecn,n)<=sum(vecm,m))
cout<<-1<<endl;
else
cout<<result<<endl;