There are n boxes arranged in a single queue. Each box has an integer i written on it. From the given queue, the participants has to select two contiguous subsequences A and B of the same size. The selected subsequences should be such that the summation of the product of the boxes should be maximum. The product is not calculated normally though. To make the game interesting, the first box of subsequence A is to be multiplied by the last box of subsequence B. The second box of subsequence A is to be multiplied by the second last box of sequence B and so on. All the products thus obtained are then added together.
Example :
input :
8
1 9 2 3 0 6 7 8
Output : 104
Explanation :
1 9 2 3 0 6 7 8
Then
A = 9 2 3
B = 6 7 8
Then
9*8 = 72
2*7 = 14
3*6 = 18
Then print 72+14+18 = 104
Attachments:
Answers
Answered by
0
Answer:
news flash of light of mathematics-Kumar Sharma have attended today's date and I have done the test is not y of social
Similar questions