Problem:
Score : 400 points

Problem Statement

We have N dice arranged in a line from left to right. The i-th die from the left shows p_i numbers from 1 to p_i with equal probability when thrown.

We will choose K adjacent dice, throw each of them independently, and compute the sum of the numbers shown. Find the maximum possible value of the expected value of this sum.

Constraints

1 ≤ K ≤ N ≤ 200000

1 ≤ p_i ≤ 1000

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N K
p_1 ... p_N

Output

Print the maximum possible value of the expected value of the sum of the numbers shown.

Your output will be considered correct when its absolute or relative error from our answer is at most 10^{-6}.

Sample Input 1

5 3
1 2 2 4 5

Sample Output 1

7.000000000000

When we throw the third, fourth, and fifth dice from the left, the expected value of the sum of the numbers shown is 7. This is the maximum value we can achieve.

Sample Input 2

4 1
6 6 6 6

Sample Output 2

3.500000000000

Regardless of which die we choose, the expected value of the number shown is 3.5.

Sample Input 3

10 4
17 13 13 12 15 20 10 13 17 11

Sample Output 3

32.000000000000

Solution in C++ (Clang 10.0.0) (judge verdict: Accepted)

#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <string>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#include <cstdio>
#include <climits>
#include <tuple>
#include <ctime>
#include <cstring>
#include <numeric>
#define FOR(i,a,n) for (int i = a; i < n; i++)
#define IFOR(i,n,a) for (int i = n; i >= a; i--)
#define mp make_pair
#define full(a) a.begin(), a.end()
#define sz(x) ((int)(x).size())
#define pii pair<int, int>
#define trav(a,x) for (auto& a : x)
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using namespace std;
const ll mod = 1e9 + 7;
const int N = 5005;

ld exp(int& a)
{
    ld p = ld(1 / ld(a));
    ld ans = 0;
    FOR(i, 1, a + 1)
    {
        ans += ld(p * ld(i));
    }
    return ans;
}

void solve()
{
    int n, k; cin >> n >> k;
    ld res = 0;
    map<int, ld> m;
    vector<int> v(n);
    FOR(i, 0, k)
    {
        int a; cin >> a;
        v[i] = a;
        if (m.find(a) != m.end())
        {
            res += m[a];
            continue;
        }
        m[a] = exp(a);
        res += m[a];
    }
    ld mx = res;
    FOR(i, k, n)
    {
        int l = v[i - k];
        int r; cin >> r;
        v[i] = r;
        res -= m[l];
        if (m.find(r) != m.end())
        {
            res += m[r];
            mx = max(mx, res);
            continue;
        }
        m[r] = exp(r);
        res += m[r];
        mx = max(mx, res);
    }
    cout << setprecision(7) << fixed << mx;

}

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    /*int tc;  cin >> tc;
    while (tc--)*/
    solve();
    return 0;
}