CF596B Wilbur and Array
题目描述
小猪威尔伯又在试图修复数组了。他有一个数组 a[1],a[2],...,a[n] 最初由 n 个0组成。第一步,他可以选择任何一个下标 i 并让其下标之后的所有元素 a[i],a[i+1],...,a[n] 加1,或者减1。他的目标是得到数组 b[1],b[2],...,b[n]。
当然,威尔伯希望使用最少的步数挑战这个目标,并要求你计算这个值。
输入格式
第一行是一个整数 n(1
输出格式
输出最小的步数。
说明/提示
In the first sample, Wilbur may successively choose indices $ 1 $ , $ 2 $ , $ 3 $ , $ 4 $ , and $ 5 $ , and add $ 1 $ to corresponding suffixes.
In the second sample, Wilbur first chooses indices $ 1 $ and $ 2 $ and adds $ 1 $ to corresponding suffixes, then he chooses index $ 4 $ and subtract $ 1 $ .