Problem: problem

AOR Ika got a water tank with a size of $ 1 $ in length and $ N $ in width. The aquarium is tall enough to hold water. The aquarium has $ N-1 $ partitions and is evenly spaced into $ N $ compartments. When water was poured here, the height of the water in each section became $ a_i $.

AOR Ika decided to remove some dividers and reduce the number of compartments to $ M $ or less. When you have removed the dividers, find the maximum sum of the water heights in each compartment.

The thickness of the partition can be ignored.



input

$ N \ M $
$ a_1 \ cdots a_N $

output

Output the maximum value of the total water height of each section in one line. Also, output a line break at the end. It is acceptable if the relative or absolute error is less than or equal to $ 10 ^ {-6} $.

Example

Input

5 3
9 1 2 3 9


Output

20.000000

Solution (in CPP):

Solution:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;


signed main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    cout << fixed << setprecision(20);

    int n, m;
    cin >> n >> m;
    vector<int> A(n);
    copy_n(istream_iterator<int>(cin), n, A.begin());
    vector<int64_t> csum(n + 1);
    for (int i = 0; i < n; i++)
        csum[i + 1] = csum[i] + A[i];
    
    const double INF = 1e18;
    auto dp = vector<vector<double>>(n + 1, vector<double>(n + 1, -INF));
    dp[0][n] = 0;
    
    for (int i = 0; i < n; i++){
        for (int j = 0; j <= n; j++){
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + A[i]);
            for (int k = 1; k <= n; k++){
                if (j - k + 1 < 0)
                    continue;
                if (i + k > n)
                    continue;
                dp[i + k][j - k + 1] = max(dp[i + k][j - k + 1], dp[i][j] + double(csum[i + k] - csum[i]) / k);
            }
        }
    }

    double ans = 0;
    for (int i = 0; i <= m; i++)
        ans = max(ans, dp[n][i]);

    cout << ans << endl;
}