 # CHFPROF- Editorial:

Author: Setter’s name
Tester: Tester’s name

CAKEWALK, EASY

# PREREQUISITES:

Greedy, Math, etc.

# PROBLEM:

In this problem, a list is given which consists of only 1’s or 0’s elements. We have to count the number of times 1’s and 0’s appear and display the count that is greater compared to other

# QUICK EXPLANATION:

First count the number of 1’s and 0’s present in the list, compare both and display the greater number.

# EXPLANATION:

First create variables n,count_1,count_0 and initialize all to 0.
Take the number of element in a list as input and store in n.
Then while taking input for list check if input is 1 or 0 and accordingly increment the values of count_1 and count_0.
Finally check which count i.e count_1 or count_0 is greater and display the greater number

# SOLUTIONS:

Setter's Solution
``````#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,count0=0,count1=0;
cin>>n;
int a[n];
for(int i = 0;i<n;i++){
cin>>a[i];
if (a[i]==0){
count0+=1;
}
else{
count1+=1;
}
}
cout<<max(count0,count1);

return 0;
}
``````
Tester's Solution
``````n = int(input())
lis = list(map(int,input().split()))
c1=0
c2=0
for x in lis:
if x==1:
c1+=1
else:
c2+=1
print(max(c1,c2))
``````