MAX Average Problem
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 5825 Accepted Submission(s): 1446 Consider a simple sequence which only contains positive integers as a1, a2 ... an, and a number k. Define ave(i,j) as the average value of the sub sequence ai ... aj, i<=j. Let’s calculate max(ave(i,j)), 1<=i<=j-k+1<=n.
There multiple test cases in the input, each test case contains two lines.
The first line has two integers, N and k (k<=N<=10^5).
The second line has N integers, a1, a2 ... an. All numbers are ranged in [1, 2000].
For every test case, output one single line contains a real number, which is mentioned in the description, accurate to 0.01.
10 6 6 4 2 10 3 8 5 9 4 1
直接斜率DP:O(N)
#include #include #include #include #include #include #include #include #include