最大子段和 import java.util.*; public class Main { public static void main(String args[]) { Scanner cin=new Scanner(System.in); int ks, n, a[]=new int[100000]; int max, sum, ts, te, s, e; ks=cin.nextInt(); for(int j=1; j<=ks; j++) { n=cin.nextInt(); for(int i=0; i<n; i++) a[i]=cin.nextInt(); e=s=te=ts=0; max=-9999999; //! sum=0; for(int i=0; i<n; i++) { if(sum>=0) { sum+=a[i]; te=i; } else { sum=a[i]; ts=te=i; } if(sum>max) { max=sum; s=ts; e=te; } } System.out.println("Case "+j+":"); System.out.println(max+" "+(s+1)+" "+(e+1)); if(j!=ks) System.out.println(""); } } }