#P1115. 最大子段和
最大子段和
Description
Given a sequence of length , choose a non-empty contiguous subarray whose sum is maximized.
Input Format
The first line contains an integer , the length of the sequence. The second line contains integers; the -th is .
Output Format
Output one line with a single integer, the answer.
7
2 -4 3 -1 2 -4 3
4
Hint
- Explanation for Sample 1: Choose the subarray , which is ; its sum is .
- Constraints:
- For 40% of the testdata, it is guaranteed that .
- For 100% of the testdata, it is guaranteed that and .
Translated by ChatGPT 5
京公网安备 11011102002149号