Main topic:
The positioning of mobile phones in cellular networks is a fundamental problem. Given that cellular networks have learned that mobile phones are in C1, C2,..., cn One of these areas, the simplest way is to simultaneously find mobile phones in these areas. But this is a waste of bandwidth. Since cellular networks can tell the probability of a mobile phone in this different region, a compromise is to divide the areas into W groups and then access them sequentially. For example, if the phone is known to be in 5 regions with probabilities of 0.3, 0.05, 0.1, 0.3, and 0.25,w=2, then one method is to access {C1,C2,C3} at the same time, and then access {C4,C5} at the same time, with the mathematical expectation that the number of accesses to the region is (0.3+0.05+0.1) + (3+2) * (0.3+0.25) = 4.1. Another method is to access {C1,C4} at the same time, and then access {C2,C3,C5}, and the mathematical expectation for the number of access areas is 2x (0.3+0.3) + (3+2) x (0.05+0.1+0.25) = 3.2.
Problem Solving Ideas:
It can be found from the formula that, in order to minimize the total expected value, the area with large probability should be placed in front of the access as far as possible.
So first sort all probabilities from big to small. Then group, you can take a continuous paragraph into a group.
F[I][J]: The first I, the minimum expected value into the J group
F[I][J] = min{F[k-1][j] + i*sum[k~i], 1<=k<=i}
#include <cstdio>#include <iostream>#include <algorithm>using namespace Std;intMain () {intT scanf"%d", &t); while(t--) {intN, W;Double sum[ the] = {0}, dp[ the][ the] = {0}, Total =0; scanf"%d%d", &n, &w); for(inti =1; I <= N; i++) {scanf ("%LF", &sum[i]); Total + =sum[i]; } sort (sum+1,sum+ N +1, greater<Double> ()); for(inti =1; I <= N; i++)sum[I] =sum[i]/total +sum[I1]; for(inti =1; I <= N; i++) {dp[i][0] =0x3f3f3f3f; for(intj =1; J <= W; J + +) {Dp[i][j] =0x3f3f3f3f; for(intK =1; K <= i; k++) Dp[i][j] = min (dp[i][j], dp[k-1][j-1] + I * (sum[I]-sum[k-1])); }} printf ("%.4lf\n", Dp[n][w]); }return 0;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
UVA-1456 Cellular Network