Hello everyone
I've come across this problem and I can't figure out how to solve it.
We have an array a of length N (1<N<60) . We write down average of all the sub arrays of a and sort them. The problem is what is the Kth number (1<K<2^N)
sample input
4 10
1 2 3 4
Sample output
8/3
What are the limits on the values of the array $$$a$$$?
Less than 60
Use DP
Let $$$dp_{j,k,x}$$$ be the number of ways to pick a subarray of $$$a$$$ using the first $$$j$$$ elements of $$$a$$$, such that this subarray has exactly $$$k$$$ elements and the sum of all chosen elements is $$$x$$$. What are the transitions? How can you use this DP to find the required number?