#P9824. [ICPC2020 Shanghai R] Fountains
[ICPC2020 Shanghai R] Fountains
题目描述
Suppose you and your teammate Mixsx will attend the Namomo Camp. The Namomo Camp will happen in consecutive days. We name the -th day as day (). The cost of day is .
Unfortunately, the schedule of the Namomo Camp conflicts with Mixsx's final exams. Mixsx has final exams every day between day and day . The exact value of and have not been announced by his college so we assume that every pair of integers and satisfying will be chosen with probability . He decides to take all the exams and thus be absent from the Namomo Camp from day to day . His will be in this case.
As Mixsx's teammate, you want Mixsx to give up his final exams and come back to the Namomo Camp. You can prepare plans before and are announced. In the -th plan (), you shut the electricity off to his college every day from day to day . You can choose the values of and as long as they are two integers satisfying .
Once and are announced, you can choose a plan () such that . Then Mixsx will come back to the Namomo Camp on every day from day to day . His loss becomes in this case. You will choose a plan that minimizes Mixsx's loss. If no plan satisfies , Mixsx will attend his final exams normally and his loss is .
Please calculate the minimum possible expected loss of Mixsx if you choose the plans optimally. Output for every from to .
Formally, given a list of numbers , define a loss function . Given an integer (), you should select integers satisfying for all , such that
$$\sum_{1\leq L\leq R\leq n} \left[C(L, R) - \max_{1\le i\le k, L \leq l_i \leq r_i \leq R} C(l_i, r_i) \right] $$is minimized. ($\max_{1\le i\le k, L \leq l_i \leq r_i \leq R} C(l_i, r_i)$ is defined as if no satisfies and .) Output the minimized value for every integer in .
输入格式
The first line contains an integer . The second line contains space separated integers .
输出格式
The output contains integers in their own lines, the expectations when multiplied by . It can be shown that the results are always integers.
题目大意
给出一个长度为 的序列 ,定义 。
对于每个 ,找出 个二元组 ,满足 ,最小化:
$$\sum_{1\leq L\leq R\leq n} \left[C(L, R) - \max_{1\le i\le k, L \leq l_i \leq r_i \leq R} C(l_i, r_i) \right] $$您只需要对于每个 输出对应的值,不需要输出方案。
1
1
0
2
13 24
26
13
0
3
6 4 7
33
21
12
8
4
0
提示
For the first test case, we only need to consider the case . We can only choose . Then the expected loss is and the result is .
For the third test case, consider the case when . We choose , and . The expected loss is . And the result is .