#P2501. [HAOI2006] 数字序列

    ID: 1515 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>动态规划,dp递推2006河南各省省选枚举,暴力

[HAOI2006] 数字序列

Description

You are given an integer sequence aa of length nn. It does not look good, so we want to turn it into a strictly increasing sequence. However, we do not want to change too many elements, and we also do not want the magnitude of changes to be too large.

Input Format

The first line contains an integer nn, the length of the sequence.
The second line contains nn integers; the ii-th integer is the ii-th element aia_i of the sequence.

Output Format

On the first line, output an integer: the minimum number of elements that need to be changed.
On the second line, output an integer: under the condition that the number of changed elements is minimal, the minimum possible sum of absolute changes.

4
5 2 3 5
1
4

Hint

Constraints

  • For 90%90\% of the testdata, it is guaranteed that n6×103n \leq 6 \times 10^3.
  • For 100%100\% of the testdata, it is guaranteed that 1n3.5×1041 \leq n \leq 3.5 \times 10^4, 1ai1051 \leq a_i \leq 10^5. The testdata guarantees that aia_i are generated at random.

Translated by ChatGPT 5