Help me in solving SUMARRAY problem

My issue

it is saying my solution failed in following input:1
2 5
my output:2 3
how can this be incorrect
there are equal number of odds and evens and sum is also 5

My code

#include <bits/stdc++.h>
using namespace std;
int main()
{
    long t;
    cin>>t;
    while(t--)
    {
        long n;
        cin>>n;
        long k;
        cin>>k;
        long sum=0;
        for(long i=1;i<=n;i++)
        {
            sum+=i;
        }
        if(n%2==1)
        cout<<-1<<endl;
        else if(k>=sum)
        {
            if(k%2==0&&((n/2)%2==1))
            cout<<-1<<endl;
            else if(k%2==1&&((n/2)%2==0))
            cout<<-1<<endl;
            else{
            long sum1=0;
            for(long i=1;i<=n-2;i++)
            {
                cout<<i<<" ";
                sum1+=i;
            }
            cout<<(k-sum1)/2<<" "<<((k-sum1)/2)+1<<endl;}
        }
        else
        cout<<-1<<endl;
    }

     return 0;   
}

Problem Link: SUMARRAY Problem - CodeChef

Ignore the “Debug my code” output for this problem. Since there are multiple answers possible, this feature will not work on this problem. Your code would be failing on some other test case.