Analysis:
A state is a set of ordered collections that do not intersect and are set to all regions. It is obvious that enumerating the elements of a collection is not bearable,
Write the desired formula, you will find a greedy, when the size of each set is determined, the probability of a large priority access is optimal. It's easy to prove and intuitive.
So first you sort from big to small. The definition state F[i][j] represents the minimum expectation of the group I, starting with J.
Transfer is enumeration divided by K, then there is f[i][j] = min{f[i-1][k]+ (k-j) * (U[n]-u[j-1])},k>j
Boundary F[1][j] = (n-j+1) * (U[n]-u[j-1])
#include <bits/stdc++.h>using namespacestd;Const intMAXN = 1e4+4;intU[MAXN];intf[101][MAXN];Const intINF =0x3f3f3f3f;//#define LOCALintMain () {#ifdef LOCAL freopen ("In.txt","R", stdin);#endif intT Cin>>u; while(t--){ intN,w; scanf"%d%d",&n,&W); for(inti =1; I <= N; i++) scanf ("%d". UIi); Sort (U+1. UI1+n,greater<int>()); for(inti =1; I <= N; i++) U[i] + = u[i-1]; for(intj = N; J >0; j--) {f[1][J] = (n-j+1) * (u[n]-u[j-1]); } for(inti =2; I <= W; i++){ for(intj =1; J <= N; J + +) {F[i][j]=INF; for(intK = j+1; K <= N; k++) {F[i][j]= Min (f[i-1][k]+ (K-J) * (u[n]-u[j-1]), f[i][j]); }}} printf ("%.4lf\n", f[w][1]/(Double) u[n]); } return 0;}
Uvalive 4731 Cellular Network