返回列表 發帖
  1. import java.io.BufferedReader;
  2. import java.io.InputStreamReader;

  3. public class Ch01 {

  4.         BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
  5.         String raw[];
  6.         int curMaxSum, totMaxSum;
  7.         Ch01() throws Exception
  8.         {
  9.                 raw=br.readLine().split(" ");
  10.                 for(int i=0, len=raw.length; i<len; i++)
  11.                 {
  12.                         int t=Integer.parseInt(raw[i]);
  13.                         if(i==0)
  14.                         {
  15.                                 curMaxSum=t;
  16.                                 totMaxSum=t;
  17.                         }
  18.                         curMaxSum=Math.max(curMaxSum+t, t);
  19.                         totMaxSum=Math.max(curMaxSum, totMaxSum);
  20.                 }
  21.                 System.out.println(totMaxSum);
  22.         }
  23.         public static void main(String[] args) throws Exception{
  24.                 new Ch01();
  25.         }
  26. }
複製代碼

TOP

返回列表