We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c3e2cf3 commit 4a561e3Copy full SHA for 4a561e3
Shuffling-Parities.cpp
@@ -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