Java 8,242字节
import java.util.*;v->{List a=new Stack();for(String x:new Scanner(System.in).nextLine().split(" "))a.add(new Long(x));int r=0,l=a.size(),i=l,j,k,s;for(;i-->0;)for(j=l;--j>1;r=s>r?s:r)for(s=0,k=i;k<j;)s+=(long)a.get(k++);System.out.print(r);}
在这里尝试。
不使用STDIN / STDOUT要求的106个字节。
a->{int r=0,l=a.length,i=l,j,k,s;for(;i-->0;)for(j=l;--j>1;r=s>r?s:r)for(s=0,k=i;k<j;s+=a[k++]);return r;}
在这里尝试。
说明:
import java.util.*; // Required import for List, Stack and Scanner
v->{ // Method with empty unused parameter and no return-type
List a=new Stack(); // Create a List
for(String x:new Scanner(System.in).nextLine().split(" "))
// Loop (1) over the STDIN split by spaces as Strings
a.add(new Long(x)); // Add the String converted to a number to the List
// End of loop (1) (implicit / single-line body)
int r=0, // Result-integer
l=a.size(), // Size of the List
i=l,j,k, // Index-integers
s; // Temp sum-integer
for(;i-->0;) // Loop (2) from `l` down to 0 (inclusive)
for(j=l;--j>1; // Inner loop (3) from `l-1` down to 1 (inclusive)
r= // After every iteration: change `r` to:
s>r? // If the temp-sum is larger than the current `r`:
s // Set `r` to the temp-sum
: // Else:
r) // Leave `r` the same
for(s=0, // Reset the temp-sum to 0
k=i;k<j;) // Inner loop (4) from `i` to `j` (exclusive)
s+=(long)a.get(k++);
// Add the number at index `k` in the List to this temp-sum
// End of inner loop (4) (implicit / single-line body)
// End of inner loop (3) (implicit / single-line body)
// End of loop (2) (implicit / single-line body)
System.out.print(r); // Print the result to STDOUT
} // End of method