#C620. Maximum Contiguous Subarray Sum
Maximum Contiguous Subarray Sum
Maximum Contiguous Subarray Sum
Given a single line string containing space-separated integers (both positive and negative), this problem requires you to find the contiguous subarray (which must contain at least one element) that has the greatest sum. Formally, if the list of integers is \( a_1, a_2, \dots, a_n \), you are to compute \( \max_{1 \leq i \leq j \leq n} \sum_{k=i}^{j} a_k \). In case the input string is empty, output 0.
For example, for the input "1 -3 2 1 -1 3 -2 5 -2", the maximum contiguous subarray sum is 8.
inputFormat
The input is provided via standard input (stdin) and consists of a single line of space-separated integers. The line may be empty, which should be interpreted as no numbers.
outputFormat
Print a single integer on standard output (stdout) representing the maximum sum of a contiguous subarray.
## sample1 -3 2 1 -1 3 -2 5 -2
8