Leaderboard
Showing:
Maximum Sum Bitonic Subsequence
Easy Accuracy: 51.24% Submissions: 8868 Points: 2

Given an array of integers A. A subsequence of A is called Bitonic if it is first increasing then decreasing.

Input:
The first line contains an integer T denoting the no of test cases. Each test case consist of two lines. The first line contains an integer N denoting the size of the array. Then in the next line are N space separated values of the array A[].

Output:
For each test case in a new line print the max sum bitonic subsequence.

Constraints:
1<=T<=100
1<=N<=50
1<=A[]<=100

Example:
Input:

2
6
80 60 30 40 20 10
9
1 15 51 45 33 100 12 18 9

Output:
210
194

Explanation:
Testcase2:

Input : A[] = {1, 15, 51, 45, 33, 100, 12, 18, 9}
Output : 194
 Bi-tonic Sub-sequence are :
{1, 51, 9}

{1, 50, 100, 18, 9}
{1, 15, 51, 100, 18, 9}
{1, 15, 45, 100, 12, 9}
{1, 15, 45, 100, 18, 9} .. so on           
Maximum sum Bi-tonic sub-sequence is 1 + 15 + 51 + 100 + 18 + 9 = 194  

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Maximum Sum Bitonic Subsequence

Output Window