Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 6560 |

@blackshadows | 6400 |

@mb1973 | 5777 |

@Quandray | 5275 |

@akhayrutdinov | 5111 |

@saiujwal13083 | 5074 |

@kirtidee18 | 4398 |

@sanjay05 | 3762 |

@mantu_singh | 3654 |

@gfgaccount | 3601 |

@marius_valentin_dragoi | 3525 |

Complete Leaderboard | |

Handle | Score |

@anish5256 | 991 |

@vimleshpratapsingh321 | 980 |

@skj7 | 899 |

@akhileshkumar562002 | 862 |

@kanewilliamson123 | 854 |

@pradeeppatidar1999 | 852 |

@pd420786 | 813 |

@infilooop | 800 |

@bunnybug320 | 796 |

@smitabose7826 | 784 |

@wallflowe101 | 778 |

Complete Leaderboard |

Let Max be the maximum possible mean of a multiset of values obtained from an array **Arr **of length **N**. Let Min be the minimum possible mean of a multiset of values obtained from the same array. Note that in a multiset values may repeat. The task is to find the **number of multisets** with mean as Max and the number of multisets with mean as Min. The answer may be too large so output the number of multisets modulo 10^{9}+7.

**Example 1:**

Input:N =5Arr ={3, 1, 2, 3, 4}Output:1 1Explanation:The maximum possible Mean of a Subset of the array is 4. There can be only 1 such subset - {3, 1, 2, 3,4}. The minimum possible Mean of a Subset of the array is 1. There can be only 1 such subset - {3,1, 2, 3, 4}.

**Example 2:**

Input:N =3Arr ={1, 2, 1}Output:1 3Explanation:The maximum possible Mean of a Subset of the array is 2. There can be only 1 such subset - {1,2, 1}. The minimum possible Mean of a Subset of the array is 1. There can be 3 such subsets - {1, 2, 1}; {1, 2,1}; {1, 2,1}.

**Your Task:**

You don't need to read input or print anything. Your task is to complete the function **numOfSubsets()** which takes an Integer N and an array Arr[] as input and returns a vector of two numbers- the number of multisets with mean as Max and the number of multisets with mean as Min.

**Expected Time Complexity:** O(N)

**Expected Auxiliary Space:** O(N)

**Constraints:**

1 <= N <= 10^{5}

1 <= Arr[i] <= 10^{5}

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

YesLoading...

Number of subsets and mean

...