A Really Odd Sequence
InterviewTime limit6sMemory limit512 MB
Given a sequence of integers, find the maximum sum of a contiguous subarray whose length is odd.
- Level
Medium5 of 10
- Topics
- Array, Dynamic programming, Prefix sum, Greedy
- Solved
- No attempts yet
Problem
Following our long-established tradition, the best statements are those kept short.
Given a sequence of integers, find the largest sum of a consecutive subsequence of odd length.
Input
The first line of input contains the number of test cases . The descriptions of the test cases follow.
The first line of each test case contains the length of the sequence ().
The next line contains integers (), the elements of the sequence.
The total length of all sequences in all test cases does not exceed .
Output
For each test case, output the largest sum on a separate line.