#P12815. [NERC 2021] Budget Distribution
[NERC 2021] Budget Distribution
题目描述
Distributing budgeted money with limited resources and many constraints is a hard problem. A consists of topics; -th topic consists of items. For each topic, the is known. The optimal relative distribution for the topic is a list of real numbers , where .
Let's denote the amount of money assigned to -th item of the topic as ; the total amount of money for the topic is . A of the plan for the topic is defined as $\sum\limits_{j=1}^{n_i}\left|\frac{c_{i, j}}{C_i} - p_{i, j}\right|$. Informally, the non-optimality is the total difference between the optimal and the actual ratios of money assigned to all the items in the topic. The is the sum of non-optimalities of all topics. Your task is to minimize the total plan non-optimality.
However, the exact amount of money available is not known yet. -th item of -th topic already has dollars assigned to it and they cannot be taken back. Also, there are possible values of the extra unassigned amounts of money available . For each of them, you need to calculate the minimal possible total non-optimality among all ways to distribute this extra money. You don't need to assign an integer amount of money to an item, any real number is possible, but all the extra money must be distributed among all the items in addition to already assigned. Formally, for each value of extra money you'll need to find its distribution such that and $\sum\limits_{i=1}^{t}\sum\limits_{j=1}^{n_i} d_{i,j} = x_k$, giving the resulting budget assignments that minimize the total plan non-optimality.
输入格式
The first line contains two integers () and () --- the number of topics in the budget and the number of possible amounts of extra money.
The next lines contain descriptions of topics. Each line starts with an integer () --- the number of items in -th topic; it is followed by integers (; for any , at least one of ) --- the amount of money already assigned to -th item in -th topic; they are followed by integers () --- they determine the values of as $p_{i, j} = {p'_{i, j}} \big/ {\sum\limits_{j=1}^{n_i}{p'_{i, j}}}$ with .
The next line contains integers () --- -th possible amount of extra money.
输出格式
Output real numbers --- the minimal possible non-optimality for the corresponding amount of extra money . An absolute or a relative error of the answer must not exceed .
1 5
3 1 7 10 700 400 100
0 2 10 50 102
1.0555555555555556
0.8666666666666667
0.5476190476190478
0.12745098039215708
0.0
2 5
3 10 70 100 700 400 100
3 10 30 100 700 400 100
2 10 50 70 110
2.2967032967032974
2.216776340655188
1.8690167362600323
1.7301587301587305
1.5271317829457367