Error
|
|
---|---|
@Ibrahim Nash | 6379 |
@blackshadows | 6329 |
@mb1973 | 5358 |
@Quandray | 5231 |
@akhayrutdinov | 5111 |
@saiujwal13083 | 4510 |
@sanjay05 | 3762 |
@marius_valentin_dragoi | 3522 |
@sushant_a | 3459 |
@verma_ji | 3357 |
@KshamaGupta | 3318 |
Complete Leaderboard | |
|
|
@ritiksethi21 | 1050 |
@aroranayan999 | 807 |
@RizulBansal | 685 |
@ashishtrehan002 | 538 |
@hemantgarg923 | 528 |
@simrangoyal | 526 |
@ronaldo77 | 520 |
@anishrajan | 505 |
@thanosagain | 505 |
@ssparteek470 | 495 |
@rahul2312 | 491 |
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 109+7.
Example 1:
Input: N = 5 Arr = {3, 1, 2, 3, 4} Output: 1 1 Explanation: 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 = 3 Arr = {1, 2, 1} Output: 1 3 Explanation: 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 <= 105
1 <= Arr[i] <= 105
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?
Yes