Choosing the Judges
Practice
4.1 (42 votes)
Algorithms
Approved
Dynamic programming
Easy
Open
Problem
37% Success 17244 Attempts 20 Points 3s Time Limit 256MB Memory 1024 KB Max Code

Harry was contesting to be the most stylist person in his college. He had to collect maximum points from the judges to be able to win. However there was a problem. The judges were sitting in a line and each pair of adjacent judges had ego issues with each other. So if one judge gave X points to Harry then the next judge won’t give him any points. Harry had a friend in the organizing team and through him he had found out the exact points he would get from each judge if he chose their score to be considered. Help him find out the maximum points he can score.

INPUT
The first line of input contains the number of test cases, T.
0 < T < = 10
Each test case starts with a number N, the number of judges.
0 <= N < = 10^4.
The next line will have N numbers, number of points each judge gave Harry
0 < = X(i) < = 10^9.
The order of the judges does not change.

OUTPUT
For each test case print “Case T: A” without quotes in a single line.
T is the case number, starting with 1.
A is the maximum number of points Harry can collect.

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
65 votes
Tags:
Ad-HocAlgorithmsApprovedEasyOpen
Points:20
32 votes
Tags:
EasyMathOpen
Points:20
32 votes
Tags:
Dynamic ProgrammingEasy