Get Success Value π (Fungible :)
Amazon Prime Video has recently released an exclusive series on its platform. They collected the number of viewers from n
different regions across the world and stored the data in the array num_viewers.
The success value of the release is defined as the sum of viewership in the top k regions, those with the highest viewers.
For example, if num_viewers = [3, 2, 1, 4, 5] and k = 3, then the success value of the release is
3 + 4 + 5 = 12 as [3, 4, 5] are the top 3 values.
Given a number of k values, calculate the success value for each query.
Complete the function getSuccessValue in the editor.
getSuccessValue has the following parameters:
int num_viewers[n]: viewership from n different regionsint queries[q]: an array of k valuesReturns
int[q]: the maximum possible success values for each query1Example 1
2Example 2
3Example 3
Constraints
Limits and guarantees your solution can rely on.
1 <= n <= 10^51 <= q <= 10^51 <= num_viewers[i] <= 10^91 <= queries[i] <= n