C1 - Maximum Joy (Easy Version)
This is the easy version of the problem. The difference between the two versions is that the constraints are different
With the Valentine's Day coming around the corner , it has created a buzz this week but it doesn't bother Bruno as he his constantly been programming and he his in his own world. This time around he need's your help in solving a simple problem.
Given an array of positive elements . You start at time and choose any position of the array and start visiting the array elements in left to right order (linear) till the last element where visiting each array element takes 1 second. When you reach the last element you have to revert back to position of the array and continue the process till you have visited all elements in array and the total time taken will be seconds. You have to choose a position in the array to start such that you need to obtain the sum of costs of visiting all array elements to be maximum. where cost of each element is given by :-
,
here denotes the time at which you reach the element and is the position of the element
For example if we take an array if we start from position 3 of the array then total sum of costs will be Initially you visit the 3rd element of the array in the second and then you go back to 1st element in seconds and then to the next element in seconds and then you terminate as you have visited all elements in total secs.
Find the maximum sum you can obtain.
Input Format
- The first line consists of , the number of test cases
- The first line of each test case consists of an integer
- The second line of each test case consists of an array of space separated positive integers.
Constraints
Output Format
- For each test case ouput an integer denoting the maximum sum of costs obtained
Sample Input 0
2
3
4 6 2
5
3 1 5 2 4
Sample Output 0
28
48
Explanation 0
- For second test case the total cost we get when we start from position is and is the maximum possible sum you can get
xxxxxxxxxx
with Ada.Text_IO, Ada.Integer_Text_IO;
use Ada;
procedure Solution is
-- Enter your code here. Read input from STDIN. Print output to STDOUT
end Solution