forked from SR-Sunny-Raj/Hacktoberfest2021-DSA
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcc-shufflingparities.cpp
More file actions
33 lines (29 loc) · 859 Bytes
/
cc-shufflingparities.cpp
File metadata and controls
33 lines (29 loc) · 859 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*PROBLEM STATEMENT LINK- https://www.codechef.com/SEPT21C/problems/SHUFFLIN */
#include<bits/stdc++.h>
using namespace std;
int main()
{ int t; // test cases
cin>>t;
while(t--)
{
int n; //number of integers
cin>>n;
int a[n];
for(int i=0;i<n;i++)
{
cin>>a[i];
}
int e=0,o=0; // e for even number , o for odd number
for (int i = 0; i < n; i++)
{
if(a[i]%2==0)
e++;
else
o++;
}
int ne=n/2; // number of even indices
int no=n-ne; // number of odd indices
cout<<min(e,no)+min(o,ne)<<endl;
}
return 0;
}