UVa 10883 - Supermean

It's a combinatory problem. As you see a naive solution won't work since finding means that way might take a running time of 50000^2

But we can find a sequence like this: supermean = ((n-1)C0 * a1 + (n-1)C1 * a2 + .....+(n-1)Cmid-1 * a mid + ... + (n-1)C0 * an) / 2 ^ (n-1)

which helps us to find solution in O(n)

Again the problem is, for 50000 numbers this will overflow. Hence, you can split the numbers using logarithm function. A pow function won't work!

Also consider negative numbers for logarithm. Happy hunting!