#P8118. 「RdOI R3.5」Mystery
「RdOI R3.5」Mystery
Problem Description
You are given a non-decreasing integer sequence of length and an integer .
We define the "difference measure" of two sequences of the same length as .
Now, for each integer , you need to construct a sequence of length , such that for any , , and is minimized. Here, denotes the prefix of with length , i.e., . Note that does not have to be an integer.
Input Format
The first line contains two integers .
The second line contains integers, representing .
The third line contains an integer , which specifies the output mode. See the "Output Format" for details.
Output Format
- If , output integers, one per line. The integer on line represents .
- If , you only need to output one integer on a single line, which is .
5 2
2 3 4 5 6
0
0
1
2
4
6
6 2
1 1 4 5 6 8
0
0
2
2
3
4
5
6 2
1 1 4 5 6 8
1
5
20 4
4 6 7 9 19 21 30 32 33 35 49 50 58 67 75 77 78 89 91 91
0
0
2
5
10
10
12
12
14
17
22
22
25
25
25
25
27
30
30
32
36
Hint
Sample Explanation
Sample #1
One possible construction is:
$$\begin{aligned} b_1&=\{2\}\\ b_2&=\{2,4\}\\ b_3&=\{1,3,5\}\\ b_4&=\{1,3,5,7\}\\ b_5&=\{0,2,4,6,8\}\\ \end{aligned}$$Sample #2
One possible construction is:
$$\begin{aligned} b_1&=\{1\}\\ b_2&=\{0,2\}\\ b_3&=\{0,2,4\}\\ b_4&=\{0,2,4,6\}\\ b_5&=\{-1,1,3,5,7\}\\ b_6&=\{-1,1,3,5,7,9\}\\ \end{aligned}$$Sample #3
Same as Sample #2, except that . You only need to output .
Constraints and Notes
$$\def\arraystretch{1.5} \begin{array}{|c|c|c|c|c|c|} \hline \textbf{subtask} & \textbf{Score} & \bm{{n\le}} & \bm{{T=}} & \bm{{k,a_i\le}} & \textbf{subtask dependencies}\cr\hline 1 & 30 & 100 & 0 & 100 & -\cr\hline 2 & 30 & 10^5 & 0 & 10^6 & 1\cr\hline 3 & 40 & 10^6 & 1 & 10^6 & -\cr\hline \end{array}$$For of the testdata, , , and .
Translated by ChatGPT 5