Skip to content

Commit 4a561e3

Browse files
committed
Sept Long : Shuffling Parties
1 parent c3e2cf3 commit 4a561e3

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

Shuffling-Parities.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Codechef Septempter Long Challenge DIV 3
2+
// Shuffling Parties
3+
#include<iostream>
4+
using namespace std;
5+
6+
int main()
7+
{
8+
int num_of_test_cases ;
9+
cin>>num_of_test_cases;
10+
for (int i = 0; i < num_of_test_cases; i++)
11+
{ int N ;
12+
cin>>N;
13+
int arr[N];
14+
for (int j = 0; j < N ; j++)
15+
{
16+
cin>>arr[j];
17+
}
18+
int even = 0 ;
19+
int odd = 0 ;
20+
for (int k = 0; k < N; k++)
21+
{
22+
arr[k] & 1 ? odd++ : even++;
23+
}
24+
if (N & 1)
25+
{
26+
even > odd ? cout<< (N/2) + 1 + odd<<endl : cout<< (N/2) + even;
27+
}
28+
else{
29+
even >= odd ? cout<< (N/2) + odd <<endl : cout<<even+(N/2)<<endl ;
30+
}
31+
}
32+
33+
return 0 ;
34+
}

0 commit comments

Comments
 (0)