F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Sequence Adjustment

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1317    Accepted Submission(s): 458


Problem Description
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.
 

Input
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.
 

Output
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.
 

Sample Input
2 2 2 4 6 1 1 1 2 2 2
 

Sample Output
Case 1: 2 3 Case 2: 1 2
 

Hint
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.
 

Author
wzc1989
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 09:56:21, Gzip enabled