TWINGFT Please help me...it will take just two minutes

In problem TWINGFT
can anyone please help me that why this code is giving me the wrong answer on submission …while I have the same logic with editorial’s solutions…It is giving me the right answer on normal compile and run but giving the wrong answer on submission

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
int t;
cin>>t;
while(t–)
{
int n,k;
cin>>n>>k;
ll a[n+1],first=0,second=0;
for(int i=1;i<=n;i++)
cin>>a[i];

sort(a,a+n+1, greater<int>());
for(int i=1;i<=2*k;i++ )
{
    if((i%2)!=0)
    {
        first+=a[i];
    }
    else
    {
        second+=a[i];
    }
    
}
second+=a[2*k+1];
cout<<max(first,second)<<endl;

}
return 0;
}

assign a[0]=INT_MAX before sort function

Something similar is happening to my code too, its running perfect in my compiler with the given test cases but on submission WA appears…Anyone please help us

#include <bits/stdc++.h>

using namespace std;

int main()

{

int t;

cin >> t;

int n,k;

while (t--)

{

    cin>>n>>k;

    int num[n];

    for(int i=0;i<n;i++)

    {

        cin>>num[i];

    }

    int q=sizeof(num)/sizeof(num[0]);

    sort(num,num+q,greater<int>());

    

    int s1=0,s2=0;

    for(int i=0;i<k;i++)

    {

        s1=s1+num[(2*i)];

        s2=s2+num[(2*i)+1];

    }

    s2=s2+num[2*k];

    cout<<max(s1,s2)<<endl;

}    

return 0;

}

@anukalp_pandey
Try using long long instead of int for s1 and s2