#LX0024. [ICPC2024 Xi'an I] Make Them Straight
[ICPC2024 Xi'an I] Make Them Straight
中文翻译:
有一个长度为的非负整数序列,你可以花费的代价把改成任意非负整数。
问:最少多少的代价可以把数组修改成从左到右,公差在的等差数列。
。
题目描述
There is a sequence of non-negative integers of length , the -th element of it is .
A sequence is defined as 'good' if and only if there exists a non negative integer that satisfies the following condition:
for all .
To make this sequence 'good', for each , you can do nothing, or pay coin to replace with any non-negative integer.
The question is, what is the minimum cost to make this sequence 'good'.
输入格式
The first line contains an integer , described in the statement.
The second line contains integers .
The third line contains integers .
输出格式
One integer, the answer.
5
1 4 3 2 5
1 1 1 1 1
2
5
1 4 3 2 5
1 9 1 1 1
3
相关
在以下作业中: