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 <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
double cal_max(const int current, const int max_section, const std::vector<int>& heights, std::vector<std::vector<double>>& memo) {
	if (current == heights.size()) return 0;
	if (memo[current][max_section] >= 0) return memo[current][max_section];
	if (max_section == 1) {
		double sum_height = std::accumulate(std::next(heights.begin(), current), heights.end(), 0.0);
		return memo[current][max_section] = sum_height / (heights.size() - current);
	}
	double sum_height = 0.0;
	double& result = memo[current][max_section];
	for (auto right = current; right < heights.size(); ++right) {
		sum_height += heights[right];
		result = std::max(result, cal_max(right + 1, max_section - 1, heights, memo) + sum_height / (right - current + 1));
	}
	return result;
}
int main() {
	int n, m; std::cin >> n >> m;
	std::vector<int> heights(n); for (auto& h : heights) std::cin >> h;
	std::vector<std::vector<double>> memo(n, std::vector<double>(m + 1, -1));
	std::cout << std::setprecision(10) << std::fixed << cal_max(0, m, heights, memo) << '\n';
}