Skip to content

Commit bfd4417

Browse files
committed
Added 1472AB- Fair Division
1 parent b78974e commit bfd4417

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

1472AB- Fair Division.cpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// ॐ नमः शिवाय
2+
#include<bits/stdc++.h>
3+
using namespace std;
4+
#define ll long long
5+
6+
// Code Written By: Vikash Patel
7+
// Codeforces Profile: https://codeforces.com/profile/vikashpatel
8+
9+
int main()
10+
{
11+
int t;
12+
cin>>t;
13+
while(t--)
14+
{
15+
int n;
16+
cin>>n;
17+
int a;
18+
int one=0;
19+
int sum = 0;
20+
for(int i=0;i<n;i++)
21+
{
22+
cin>>a;
23+
if(a==1)
24+
{
25+
one++;
26+
sum++;
27+
}
28+
else
29+
sum += 2;
30+
}
31+
if(sum % 2 == 0)
32+
{
33+
int div = sum/2;
34+
if(div % 2 == 0)
35+
cout<<"YES"<<endl;
36+
else
37+
{
38+
if(one)
39+
cout<<"YES"<<endl;
40+
else
41+
cout<<"NO"<<endl;
42+
}
43+
}
44+
else
45+
cout<<"NO"<<endl;
46+
}
47+
return 0;
48+
}

0 commit comments

Comments
 (0)