Pro.ID22043 TitleCircular Sequence Title链接http://10.20.2.8/oj/exercise/problem?problem_id=22043 AC11 Submit82 Ratio13.41% 时间&空间限制描述Given a sequence with n elements, if the last element is also adjacent to the first element of the sequence, the sequence is call "circular sequence". Now, here comes a simple problem: given a circular sequence, you should find a segment of the sequence, such that it contains at least one element, and the sum of the elements is as large as possible. 输入Input may contain several test cases. The first line is a single integer t, the number of test cases below. Each test case composed of two lines. The first line of each test case is a positive integer n ( 1 ≤ n ≤ 100000 ), denoting the number of elements in the circular sequence, and the second line has n integers; the absolute value of each integer is no more than 100000. 输出Description Given a sequence with n elements, if the last element is also adjacent to the first element of the sequence, the sequence is call "circular sequence". Now, here comes a simple problem: given a circular sequence, you should find a segment of the sequence, such that it contains at least one element, and the sum of the elements is as large as possible. Input Input may contain several test cases. The first line is a single integer t, the number of test cases below. Each test case composed of two lines. The first line of each test case is a positive integer n ( 1 ≤ n ≤ 100000 ), denoting the number of elements in the circular sequence, and the second line has n integers; the absolute value of each integer is no more than 100000. Output For each test case, output the maximum segment sum in a single line. Sample Input 2 Sample Output -1 Source 样例输入2 样例输出-1 作者 |