Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
To calculate the average of a subarray, you need the sum and the K. K is already given. How could you quickly calculate the sum of a subarray?
Use the Prefix Sums method to calculate the subarray sums.
It is possible that the sum of all the elements does not fit in a 32-bit integer type. Be sure to use a 64-bit integer type for the prefix sum array.