Maximize count of equal numbers in Array of numbers upto N by replacing pairs with their sum | C ++ implementation of the above approach ; Function to count maximum number of array elements equal ; Driver Code ; Function Call
#include <bits/stdc++.h> NEW_LINE using namespace std ; int countEqual ( int n ) { return ( n + 1 ) / 2 ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 , 6 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << countEqual ( n ) ; return 0 ; }