当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3434:Sequence Adjustment

题目描述
Given a sequence consists of N integers. Each time you can choose a continuous subsequence and add 1 or minus 1 to the numbers in the subsequence .You task is to make all the numbers the same with
the least tries. You should calculate the number of the least tries
you needed and the number of different final sequences with the least tries.
输入解释
In the first line there is an integer T, indicates the number of test cases.(T<=30)
In each case, the first line contain one integer N(1<=N<=10^6),
the second line contain N integers and each integer in the sequence is between [1,10^9].
There may be some blank lines between each case.
输出解释
For each test case , output “Case d: x y “ where d is the case number
counted from one, x is the number of the least tries you need and y
is the number of different final sequences with the least tries.
输入样例
2
2
2 4
6
1 1 1 2 2 2
输出样例
Case 1: 2 3
Case 2: 1 2
提示
In sample 1, we can add 1 twice at index 1 to get {4,4},or 
minus 1 twice at index 2 to get {2,2}, or we can add 1 once at index 1 
and minus 1 once at index 2 to get {3,3}. So there are three different final sequences.
来自杭电HDUOJ的附加信息
Author wzc1989
Recommend zhouzeyong

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-3434

最后修改于 2020-10-25T23:03:29+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 32768/32768K(Java/Others)