text: Maximize count of subsets into which the given array can be split such that it satisfies the given condition | C # program for the above approach ; Function to count maximum subsets into which the given array can be split such that it satisfies the given condition ; Sort the array in decreasing order ; Stores count of subsets possible ; Stores count of elements in current subset ; Traverse the array arr [ ] ; Update size ; If product of the smallest element present in the current subset and size of current subset is >= K ; Update maxSub ; Update size ; Driver Code ; Given array ; Size of the array ; Given value of X
code: using System ; class GFG { static void maxDivisions ( int [ ] arr , int N , int X ) { Array . Sort ( arr ) ; Array . Reverse ( arr ) ; int maxSub = 0 ; int size = 0 ; for ( int i = 0 ; i < N ; i ++ ) { size ++ ; if ( arr [ i ] * size >= X ) { maxSub ++ ; size = 0 ; } } Console . WriteLine ( maxSub ) ; } public static void Main ( ) { int [ ] arr = { 1 , 3 , 3 , 7 } ; int N = arr . Length ; int X = 3 ; maxDivisions ( arr , N , X ) ; } }