#P1121. 环状最大两段子段和
环状最大两段子段和
Description
Given a circular sequence of length (that is, and are adjacent), choose two contiguous, non-overlapping, and non-empty subarrays whose total sum is maximized.
Input Format
The first line contains an integer , the length of the sequence. The second line contains integers describing the sequence ; the -th number is .
Output Format
Output a single integer on one line: the maximum possible sum of two subarrays.
7
2 -4 3 -1 2 -4 3
9
Hint
Constraints
For all test points, it is guaranteed that and .
Translated by ChatGPT 5
京公网安备 11011102002149号