Submit | All submissions | Best solutions | Back to list |
ARRPRM - Prime is fun |
You will be given an array A. You can pick X (where X is a prime) consecutive elements from the array A so that the sum is maximized. Note that you can select multiple consecutive elements.
For example, if you are given an array with 10 elements, then one of ways you can select elements by selecting 1st, 2nd element then 4th, 5th, 6th element then 8th, 9th elements.
Another way can be to select 1st and 2nd element then select 4-10 elements.
Input
The first line of the input will be an integer t, denoting the number of the test cases.
For each test case, there will be an integer n, denoting the size of the array A.
Next line there will be n integers denoting the elements of the array A.
Output
For each test case, print the maximized sum (as discussed above) in a line.
Constraints
1 ≤ t ≤ 100
1 ≤ n ≤ 2000
1 ≤ elements of the array A ≤ 100000
Sample
Input: 2 4 1 2 3 4 10 10 1 1 1 1 1 1 2 2 2 Output: 9 21
Added by: | Jamil Siam |
Date: | 2017-01-12 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 GOSU |
hide comments
|
|||||
2017-01-24 17:40:25
Can't we pick all the numbers in both cases.picking(2+2) in first and (3+7) elements in the second case? |