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 <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    double waters_cumulative_sum[N + 1];
    waters_cumulative_sum[0] = 0;
    for(int i = 1; i <= N; i++){
        double water;
        cin >> water;
        waters_cumulative_sum[i] = waters_cumulative_sum[i - 1] + water;
    }
    double dp[N + 1][N], dp_next[N + 1][N];
    for(int i = 1; i <= N; i++){
        for(int j = 0; j < N; j++){
            dp[i][j] = (i > M) * -1e12 + (waters_cumulative_sum[N] - waters_cumulative_sum[j]) / (N - j);
        }
    }
    for(int i = N - 1; i >= 1; i--){
        for(int j = 1; j <= N; j++){
            for(int k = 0; k < i; k++){
                dp_next[j][k] = max(dp[j][k], dp[j + 1][i] + (waters_cumulative_sum[i] - waters_cumulative_sum[k]) / (i - k));
            }
            for(int k = i; k < N; k++){
                dp_next[j][k] = -1e12;
            }
        }
        for(int j = 1; j <= N; j++){
            for(int k = 0; k < N; k++){
                dp[j][k] = dp_next[j][k];
            }
        }
    }
    cout << fixed << setprecision(10) << dp[1][0] << endl;
}