Unable to pass test cases

I am able to pass just 2 test cases… Please help!
My code:
#include
#include
#include
#define ll long long int
using namespace std;

ll minDiff (ll boys[], ll girls[], ll n, ll m)
{
ll sum = 0;
ll jChange = 0;
for (ll i = 0; i < n; i++)
{
ll ans = 100000000;
for (ll j = 0; j < m - i; j++)
{
ll num = min(ans, abs(girls[j] - boys[i]));
if (num < ans)
{
ans = num;
jChange = j;
}
}
if (ans == 100000000)
{
sum += girls[0];
}
else
{
sum += ans;
}
girls[jChange] = 10000000 + jChange;
sort(girls, girls + m);
}
return sum;
}

int main()
{
ll n = 0, m = 0;
cin >> n >> m;
ll boys[n];
ll girls[m];
for (ll i = 0; i < n; i++)
{
cin >> boys[i];
}
for (ll i = 0; i < m; i++)
{
cin >> girls[i];
}
sort(boys, boys + n);
sort(girls, girls + m);
cout << minDiff(boys, girls, n, m) << endl;

return 0;

}

hi @kllaveyaj_4858b228ab6faf75,
refer here https://ide.codingblocks.com/s/659521 , ive commented the code

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.