Code is Successfully Executed, but on Submission shows Wrong Answer.

Need Help!! my code is successfully executed in Code,Compile & Run Panel of Codechef but on submission shows Wrong answer. The Question Code is ENTEXAM(Entrance Exam) of Begineer level.And, my code is:

#include<bits/stdc++.h>
using namespace std;
 
int main()
{
    int t;
    cin>>t;
    while(t>0)
    {
        int n,k,p,m,i,j;
        long long int sum,temp;
        cin>>n>>k>>p>>m;
        long long int total[n-1];
        for(i=0;i<n-1;++i)
        {
            sum=0;
            for(j=0;j<p;++j)
            {
                cin>>temp;
                sum+=temp;
            }
        total[i]=sum;
        }
        sum=0;
        for(i=0;i<p-1;++i)
        {
            cin>>temp;
            sum+=temp;
        }
        sort(total,total+(n-1));
        if ((k>n)||(sum>total[n-k-1]))
        cout<<"\n";
        else
        {
            if((total[n-k-1]+1)-sum<=m)
            cout<<(total[n-k-1]+1)-sum;
            else
            cout<<"Impossible";
        }
        t--;
    }
    return 0;
}

You aren’t leaving printing answer in different lines in cout<<“Impossible” and cout<<“total[n-k+1]-sum” using endl or “\n”

Also cout<<"\n" doesn’t seem correct

Try a test of your own with multiple test cases ie. t>= 2

//