import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int group = sc.nextInt();
int icase = 1;
while (group-- > 0) {
int length = sc.nextInt();
int maxSum = Integer.MIN_VALUE;
int maxBegin = 1;
int maxEnd = 1;
int begin = 1;
int end = 1;
int element;
int tempSum = 0;
for (int i = 1; i <= length; i++) {
element = sc.nextInt();
if (tempSum < 0) {
begin = i;
end = i;
tempSum = element;
} else {
end = i;
tempSum = tempSum + element;
}
if (tempSum > maxSum) {
maxSum = tempSum;
maxBegin = begin;
maxEnd = end;
}
}
System.out.println("Case " + icase + ":");
System.out.println(maxSum + " " + maxBegin + " " + maxEnd);
if (group != 0) {
System.out.println();
}
icase++;
}
}
}
hdu acm 1003 Max Sum
最新推荐文章于 2021-07-27 21:50:39 发布