English, asked by amanvij121, 6 months ago

A food fest is organised at the JLN stadium. The stalls from different states and cities have been set up. To make the fest more interesting, multiple games have been arranged which can be played by the people to win the food vouchers. One such game to win the food vouchers is described below:


There are N number of boxes arranged in a single queue. Each box has an integer I written on it. From the given queue, the participant 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 subsequence B and so on. All the products thus obtained are then added together.


If the participant is able to find the correct such maximum summation, he/she will win the game and will be awarded the food voucher of the same value.


Note: The subsequences A and B should be disjoint.


Example:

Number of boxes, N = 8

The order of the boxes is provided below:





Subsequence A





Subsequence B





The product of the subsequences will be calculated as below:





P1 = 9 * 8 = 72

P2 = 2 * 7 = 14

P3 = 3 * 6 = 18


Summation, S = P1 + P2 + P3 = 72 + 14 + 18 = 104


This is the maximum summation possible as per the requirement for the given N boxes.


Tamanna is also in the fest and wants to play this game. She needs help in winning the game and is asking for your help. Can you help her in winning the food vouchers?



Input Format
The first line of input consists of the number of boxes, N.

The second line of input consists of N space-separated integers.



Constraints
1< N <=3000

-106 <= I <=106

Output Format
Print the maximum summation of the product of the boxes in a separate line.

Sample TestCase 1
Input
8
1 9 2 3 0 6 7 8
Output
104
Explanation
As explained in the example above.

Time Limit(X):
0.50 Sec(S) For Each Input.
Memory Limit:
512 MB
Source Limit:
100 KB
Allowed Languages:
C, C++, C++11, C++14, C#, Java, Java 8, Kotlin, PHP, PHP 7, Python, Python 3, Perl, Ruby, Node Js, Scala, Clojure, Haskell, Lua, Erlang, Swift, VBnet, Js, Objc, Pascal, Go, F#, D, Groovy, Tcl, Ocaml, Smalltalk, Cobol, Racket, Bash, GNU Octave, Rust, Common LISP, R, Julia, Fortran, Ada, Prolog, Icon, Elixir, CoffeeScript, Brainfuck, Pypy, Lolcode, Nim, Picolisp, Pike, Whitespace, Pypy3

Answers

Answered by gowsshaik6499
54

Answer:

n=int(input())

l=[]

tot=0

for i in range(0,n):

   s=int(input())

   l.append(s)

#print(l)

sub=len(l)/2

re=[]

while(True):

   if(len(l)==2):

       pass

       break

   else:

       z=l[1]

       v=l[-1]

       p=z*v

       re.append(p)

       l.remove(z)

       l.remove(v)

for i in re:

   tot=tot+i

print(tot)

Explanation:

we just need to good at list methods and loops

Answered by Mithalesh1602398
0

Answer:

A single queue has N number of boxes that are organised. I have typed an integer on each box. The participant must choose two adjacent subsequences A and B that are the same size from the provided queue. The subsequences chosen should ensure that the total of the box product is at its maximum. However, the product's calculation is not done regularly. In order to keep the game engaging, the first

Explanation:

Step : 1 The JLN stadium hosts a culinary festival. There are now put up the stalls from various cities and states. A variety of activities that visitors may play to earn food coupons have been set up to add interest to the festival. Following is an example of one of these contests to earn meal coupons:

Step : 2  A single queue has N number of boxes that are organised. I have typed an integer on each box. The participant must choose two adjacent subsequences A and B that are the same size from the provided queue. The subsequences chosen should ensure that the total of the box product is at its maximum. However, the product's calculation is not done regularly. In order to keep the game engaging, the first

Step : 3  If the participant is able to find the correct such maximum summation, he/she will win the game and will be awarded the food voucher of the same value.

Note: The sub sequences A and B should be disjoint.

To learn more about similar questions visit:

https://brainly.in/question/5298713?referrer=searchResults

https://brainly.in/question/9879010?referrer=searchResults

#SPJ3

Similar questions