Cellular Network
Time limit1sMemory limit128 MB
You sort n cells by their probabilities and split them into w ordered zones to minimize the expected number of paged cells.
- Level
Medium7 of 10
- Topics
- Dynamic programming, Sorting, Probability
- Solved
- No attempts yet
Problem
A cellular network is a radio network made up of cells, each served by a base station in the cell. The base station receives call signals from the mobile users in its cell and connects those calls to the wired land-line telephone network. To route an incoming call to a mobile, the network must know which cell the mobile is currently in.
Mobiles move from cell to cell. If a mobile reported every boundary crossing, the network would always know its exact cell and paging (finding the mobile) would be trivial. In practice this is infeasible because radio bandwidth is limited, so when a call arrives the network knows only a limited set of cells the mobile might be in. Many paging strategies exist to locate a mobile efficiently; the goal is to minimize both the delay and the cost of paging until the mobile is found.
Formally, the location area is a set of cells , and the mobile is guaranteed to be in exactly one of them when a call arrives. In one paging round (one unit of time) the network can page any subset of these cells and learn whether the mobile is among the paged cells. Paging all cells in a single round is the fastest strategy but uses a lot of bandwidth.
The network can often estimate the mobile's whereabouts as independent probabilities: let be the probability that the mobile is in cell . A sequential paging strategy pages the cells one per round and stops as soon as the mobile is found. Its average cost (number of cells paged) and average delay (number of rounds) are:
A parallel paging strategy pages several cells simultaneously. Sequential paging has a lower cost than parallel paging but a larger delay. Parallel paging partitions the location area into an ordered series of groups called paging zones. Let be a partition of into non-empty zones. When a call arrives, all cells of are paged in the first round; if the mobile is not found, all cells of are paged in the second round, and so on. Let and let the zone probability be . Then:
Parallel paging trades bandwidth for time: increasing the number of zones tends to lower the cost, while decreasing it tends to raise the cost. Even for a fixed number of zones, the cost depends on how the cells are partitioned.
For example, take cells with these probabilities:
Partitioning into and gives:
Partitioning into and gives:
Given the number of cells, each cell's probability, and a fixed number of paging zones, partition the cells into zones so that the average paging cost is minimized.
Input
The input begins with a line containing the number of test cases . Each test case consists of two lines. The first line contains two integers and : the number of cells in the location area and the number of paging zones, with . The second line contains integers ; the probability of cell is . Every is between 1 and 10000.
Output
For each test case, print exactly one line containing the minimum average paging cost needed to locate the mobile, rounded to exactly 4 digits after the decimal point (round half up).