luogu#P9325. [CCC 2023 S2] Symmetric Mountains
[CCC 2023 S2] Symmetric Mountains
题目描述
Rebecca is a tour guide and is trying to market the Rocky Mountains for her magazine. She recently took a beautiful picture consisting of mountains where the mountain from the left has a height . She will crop this picture for her magazine, by possibly removing some mountains from the left side of the picture and possibly removing some mountains from the right side of the picture. That is, a crop consists of consecutive mountains starting from the to the mountain where . To please her magazine readers, Rebecca will try to find the most symmetric crop.
We will measure the of a crop as the sum of the absolute difference for every pair of mountains equidistant from the midpoint of the crop. To help understand that definition, note that the absolute value of number , written as , is the non-negative value of v: for example and . The asymmetric value of a crop is the sum of all for . To put that formula in a different way, we pair up the mountains working from the outside in toward the centre, calculate the absolute difference in height of each of these pairs, and sum them up.
Because Rebecca does not know how wide the picture needs to be, for all possible crop lengths, find the asymmetric value of the most symmetric crop (the crop with the minimum asymmetric value).
输入格式
The first line consists of an integer , representing the number of mountains in the picture.
The second line consists of space-separated integers, where the integer from the left represents .
The following table shows how the available 15 marks are distributed:
Marks | Bounds on | Bounds on | Additional Constraints |
---|---|---|---|
None. | |||
Height of mountains are in non-decreasing order from left to right. | |||
None. |
输出格式
Output on one line space-separated integers, where the integer from the left is the asymmetric value of the most symmetric picture of crops of length .
题目大意
Rebecca 有一张落基山脉的照片,上面排列着 座山,从左向右的第 座山的高度是 。Rebecca 截图保留照片的一个连续段,这张截图的不对称性定义为:处于截图上对称位置的山的高度差的绝对值之和(截图最左和最右的山的高度差,左数第二和右数第二的山的高度差,诸如此类的和)。
Rebecca 想要知道对于长度为 的截图,拥有的最小不对称性。请你对于 ,输出这个值。
7
3 1 4 1 5 9 2
0 2 0 5 2 10 10
4
1 3 5 6
0 1 3 7
提示
Explanation of Output for Sample Input :
We will show why the fifth value from the left is .Let us try to compute all the asymmetric values of crops with length .
The height of the mountains in the first crop is . The asymmetric value of this crop is .
The height of the mountains in the second crop is . The asymmetric value of this crop is .
The height of the mountains in the last crop is . The asymmetric value of this crop is .
Hence, the most symmetric crop of length is .
Explanation of Output for Sample Input :
This sample satisfies the second subtask. Note that the only crop of length is which has asymmetric value of .
本题采用捆绑测试:
-
Subtask 1(5 points):,。
-
Subtask 2(5 points):,,保证山的高度从左到右单调不减。
-
Subtask 3(5 points):,。