Help me in solving ADJSUMPAR problem

My issue

why only if the sum of elements of array B is even then only we are able to get a valid array A?

My code

#include <iostream>
using namespace std;

int main() {
int T;cin>>T;
for(int i=0;i<T;i++){
    int N;cin>>N;
    int A[N];int B[N];
    int sum=0;
    for(int i=0;i<N;i++){
    else cout<<"NO"<<endl;
	return 0;

Problem Link: ADJSUMPAR Problem - CodeChef

its because if b[i] is 1 it must have came from {odd ,even} or {even odd} sum from a,
Now when u think it of a bit u will see that is not possible to have odd number of ones is B cozz B is generated using A where each A[i] is used twice which will never generate odd number of ones.