#P4331. [BalticOI 2004] Sequence (Day1)
[BalticOI 2004] Sequence (Day1)
Description
Given a sequence , find an increasing sequence such that the sum of absolute differences is minimized.
Input Format
The first line contains an integer . The next lines each contain an integer, representing the given sequence values .
Output Format
The first line should contain the minimum sum of absolute differences. The next lines should each contain an integer, representing the sequence values .
7
9
4
8
20
14
15
18
13
6
7
8
13
14
15
18
Hint
Constraints
For of the testdata, , .
Notes
Translated from BalticOI 2004 Day1 C Sequence. Thanks to @TimeTraveller for providing the SPJ.
Translated by ChatGPT 5
京公网安备 11011102002149号