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


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

TOP

返回列表