标签:tle static string hdu [1] style result sequence tween
1 import java.util.Scanner; 2 3 public class Test4 { 4 5 public static void main(String[] args) { 6 7 int[] dp=new int[100005]; 8 int[] arrs=new int[100005]; 9 10 Scanner input=new Scanner(System.in); 11 12 int T=input.nextInt();//测试用例个数 13 for(int i=0;i<T;i++) { 14 15 int start,end,left,submax; 16 17 int n=input.nextInt(); 18 for(int j=0;j<n;j++) { 19 20 arrs[j]=input.nextInt(); 21 22 } 23 24 dp[0]=submax=arrs[0]; 25 start=end=left=1; 26 27 for(int j=1;j<n;j++) { 28 29 if(arrs[j]>arrs[j]+submax) { 30 31 submax=arrs[j]; 32 left=j+1; 33 34 }else { 35 36 submax=submax+arrs[j]; 37 38 } 39 40 if(dp[j-1]>=submax) { 41 42 dp[j]=dp[j-1]; 43 44 }else { 45 46 dp[j]=submax; 47 start=left; 48 end=j+1; 49 50 } 51 52 } 53 54 System.out.println("case"+(i+1)+":"+dp[n-1]+" "+left+" "+end); 55 56 } 57 58 } 59 60 }
标签:tle static string hdu [1] style result sequence tween
原文地址:http://www.cnblogs.com/xuzhiyuan/p/7815489.html