#CODEFORCESP331. Make It Increasing
Make It Increasing
Make it Increasing
题面翻译
题目描述
给定一个包含 个正整数的数列 以及一个长度为 的数列 ,初始时数列 的每一个元素都为0。定义一次操作为把数列 中的某个元素 加上或减去 的值,求使得数列 严格递增最小的操作次数。
输入格式
第一行为一个整数 ,第二行为 个正整数, , , ... , ,作为数列 的值。
输出格式
输出使数列 严格递增的最小操作次数。
题目描述
You are given an array consisting of positive integers, and an array , with length . Initially for each .
In one move you can choose an integer ( ), and add to or subtract from . What is the minimum number of moves needed to make increasing (that is, every element is strictly greater than every element before it)?
输入格式
The first line contains a single integer ( ).
The second line contains integers, , , ..., ( ) — the elements of the array .
输出格式
Print a single integer, the minimum number of moves to make increasing.
样例 #1
样例输入 #1
5
1 2 3 4 5
样例输出 #1
4
样例 #2
样例输入 #2
7
1 2 1 2 1 2 1
样例输出 #2
10
样例 #3
样例输入 #3
8
1 8 2 7 3 6 4 5
样例输出 #3
16
提示
Example : you can subtract from , and add , , and to , , and respectively. The final array will be [ , , , , ] after moves.
Example : you can reach [ , , , , , , ] in moves.