Algorithm
Code Examples
#1 Code Example with C++ Programming
Code -
C++ Programming
#include<bits/stdc++.h>
using namespace std;
int main(){
int t;
cin>>t;
int n, x;
while(t--){
cin>>n;
int count1 = 0, count2 = 0;
for(int i = 0; i < n; i++){
cin>>x;
if(x == 1){
count1++;
continue;
}
count2++;
}
if(count2 % 2 == 0 && count1 % 2 == 0){
cout<<"YES"<<endl;
continue;
}
if(count2 % 2 != 0 && count1 % 2 == 0 && count1 > 0){
cout<<"YES"<<endl;
continue;
}
cout<<"NO"<<endl;
}
return 0;
}
Copy The Code &
Try With Live Editor
Input
5
2
1 1
2
1 2
4
1 2 1 2
3
2 2 2
3
2 1 2
2
1 1
2
1 2
4
1 2 1 2
3
2 2 2
3
2 1 2
Output
YES
NO
YES
NO
NO
NO
YES
NO
NO
Demonstration
Codeforcess Solution 1472-B B. Fair Division ,C++, Java, Js and Python,1472-B,Codeforcess Solution