Home STD Contest Notification Clarification Problems Ranklist Status Print Sign Out
比赛题目已经加到题库最后,欢迎继续AC~More...

Max Sum II

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


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

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

Output
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
2 2 6 -5 5 6 -1 0 -2 3
 

Sample Output
Case 1: 1 6 Case 2: 2 9
 

Author
Westwind Bolws@HDU
 

Statistic | Submit | Clarifications | Back