#include <stdio.h> #include <string.h> #include <algorithm> using namespace std; double dp[2024][105]; int main() { int n, m; int i, j, k, a, b; double A[2024], sum[2024]; while(scanf("%d %d", &n, &m) == 2) { sum[0] = 0; for(i = 1; i <= n; i++) { scanf("%lf", &A[i]); sum[i] = sum[i-1] + A[i]; } for(int i = 0; i <= n; i++) for(int j = 0; j <= m; j++) dp[i][j] = 1e+30; dp[0][0] = 0; for(int i = 1; i <= n; i++) { for(int j = 1; j <= m; j++) { for(int k = i; k >= 1; k--) { dp[i][j] = min(dp[i][j], dp[k-1][j-1] + (sum[i]-sum[k-1]) * i); } } } printf("%.1lf\n", dp[n][m]); } return 0; }