#K62902. Maximum Subarray Sum

    ID: 31634 Type: Default 1000ms 256MiB

Maximum Subarray Sum

Maximum Subarray Sum

This problem requires you to find the maximum subarray sum from a given sequence of integers using Kadane's algorithm.

The algorithm can be described by the following recurrence relations in LaTeX format:

$$max_{current} = \max(a_i, max_{current} + a_i)$$ and
$$max_{global} = \max(max_{global}, max_{current})$$

You are given an array where each element \(a_i\) satisfies \(-1000 \leq a_i \leq 1000\) and the number of elements \(N\) satisfies \(1 \leq N \leq 1000\). The goal is to output the sum of the contiguous subarray with the largest sum. Note that if the input array is empty, the output should be 0. ## inputFormat Input is a single line containing space-separated integers representing the elements of the array. ## outputFormat Output a single integer which is the sum of the maximum subarray.## sample
-2 1 -3 4 -1 2 1 -5 4
6
$$