i have applied all the test cases I can think of but i am still getting wrong answer can anyonr look into my code.

Question-https://www.codechef.com/problems/MAXDIFF

here is my code

```
#include <bits/stdc++.h>
using namespace std;
int main()
{
long long int t;
cin>>t;
int n,k;
while(t--)
{
cin>>n>>k;
long long int weight[n+1];
long long int sum1=0,sum2=0,sum=0,diff1,diff2;
for(int i=0;i<n;i++)
{
cin>>weight[i];
sum+=weight[i];
}
sort(weight,weight+n);
for(int i=0;i<k;i++)
sum1+=weight[i];
for(int i=k;i<n;i++)
sum2+=weight[i];
diff1=abs(2*sum1-sum);
diff2=abs(2*sum2-sum);
if(diff1>diff2)
cout<<diff1<<"\n";
else
cout<<diff2<<"\n";
}
return 0;
}
```