Problem2070--Max Sum II

2070: Max Sum II

Time Limit: 1 Sec  Memory Limit: 512 MB
Submit: 1  Solved: 1
[Submit] [Status] [Web Board] [Creator:]


Given a sequence a[1],a[2],a[3]......a[n], you can cut the sequence into one or more consecutive sub-sequences as you want, for example, you can cut them into (a[1]...a[j]), (a[k]...a[l]), (a[m]...a[n]),1≤j<k≤l<m≤n. Your job is to make the maximum sum using the least number of consecutive sub-sequences. For example, given (6,-1,0, -2, 3), the max sum in this sequence is 9, the number of sub-sequences is 2 not 3, they are(6), (3).


The first line of the input contains an integer T(1<=T<=20) which means the number of test cases. Then T lines follow, each line starts with a number N(1<=N<=1000000), then N integers followed(all the integers are between -1000 and 1000).


For each test case, you should output two lines. The first line is "Case #:", # means the number of the test case. The second line contains two integers, the number of consecutive sub-sequences and the max sum. Output a blank line between two cases.

Sample Input Copy

2 6 -5
5 6 -1 0 -2 3

Sample Output Copy

Case 1:
1 6

Case 2:
2 9


if the sum<=0, please print 0 0.