C # program to equally divide n elements into two sets such that second set has maximum distinct elements .
using System ; class GFG { static int distribution ( int [ ] arr , int n ) { Array . Sort ( arr ) ; int count = 1 ; for ( int i = 1 ; i < n ; i ++ ) if ( arr [ i ] > arr [ i - 1 ] ) count ++ ; return Math . Min ( count , n / 2 ) ; }