Maximum subarray sum - MarisaOJ: Marisa Online Judge

Maximum subarray sum

Time limit: 1000 ms
Memory limit: 256 MB
You are given an integers array $A$ of $n$ elements. Find the subarray with maximum sum. A subarray is a contiguous sequence of elements within an array. For example, given an array $B = [1, 2, 3, 4, 5]$, array C = $[2, 3, 4]$ is a subarray of $B$. ### Input - The first line contains an integer $n$. - The second line contains $n$ integers $A_i$. ### Output - Print an integer which is the maximum subarray sum. ### Constraints - $1 \le n \le 10^5$. - $|A_i| \le 10^9$. ### Example Input: ``` 5 1 3 -2 3 -5 ``` Output: ``` 5 ```