#C8392. Maximum Subarray Sum

    ID: 52369 Type: Default 1000ms 256MiB

Maximum Subarray Sum

Maximum Subarray Sum

Given a list of integers, find the maximum sum of any contiguous subarray. This is a well-known problem that can be efficiently solved using Kadane's algorithm. Formally, if the input array is \(A = [a_1, a_2, \dots, a_n]\), you need to compute the maximum value of \(a_i + a_{i+1} + \dots + a_j\) for all \(1 \le i \le j \le n\).

inputFormat

The input is given via standard input (stdin) as a single line of space-separated integers representing the elements of the array.

outputFormat

Print to standard output (stdout) a single integer which is the maximum sum of any contiguous subarray of the given list.

## sample
-2 1 -3 4 -1 2 1 -5 4
6